This module contains general purpose URL functions not found in the standard library.
Some of the functions that used to be imported from this module have been moved to the w3lib.url module. Always import those from there instead.
Function | _is_filesystem_path |
Undocumented |
Function | _is_posix_path |
Undocumented |
Function | _is_windows_path |
Undocumented |
Function | add_http_if_no_scheme |
Add http as the default scheme if it is missing from the url. |
Function | escape_ajax |
Return the crawleable url according to: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started |
Function | guess_scheme |
Add an URL scheme if missing: file:// for filepath-like input or http:// otherwise. |
Function | parse_url |
Return urlparsed url from the given argument (which could be an already parsed url) |
Function | strip_url |
Strip URL string from some of its components: |
Function | url_has_any_extension |
Undocumented |
Function | url_is_from_any_domain |
Return True if the url belongs to any of the given domains |
Function | url_is_from_spider |
Return True if the url belongs to the given spider |
Return the crawleable url according to: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started
>>> escape_ajax("www.example.com/ajax.html#!key=value") 'www.example.com/ajax.html?_escaped_fragment_=key%3Dvalue' >>> escape_ajax("www.example.com/ajax.html?k1=v1&k2=v2#!key=value") 'www.example.com/ajax.html?k1=v1&k2=v2&_escaped_fragment_=key%3Dvalue' >>> escape_ajax("www.example.com/ajax.html?#!key=value") 'www.example.com/ajax.html?_escaped_fragment_=key%3Dvalue' >>> escape_ajax("www.example.com/ajax.html#!") 'www.example.com/ajax.html?_escaped_fragment_='
URLs that are not "AJAX crawlable" (according to Google) returned as-is:
>>> escape_ajax("www.example.com/ajax.html#key=value") 'www.example.com/ajax.html#key=value' >>> escape_ajax("www.example.com/ajax.html#") 'www.example.com/ajax.html#' >>> escape_ajax("www.example.com/ajax.html") 'www.example.com/ajax.html'
Strip URL string from some of its components: