urlparse

Parse (absolute and relative) URLs.

urlparse module is based upon the following RFC specifications.

RFC 3986 (STD66): “Uniform Resource Identifiers” by T. Berners-Lee, R. Fielding and L. Masinter, January 2005.

RFC 2732 : “Format for Literal IPv6 Addresses in URL’s by R.Hinden, B.Carpenter and L.Masinter, December 1999.

RFC 2396: “Uniform Resource Identifiers (URI)”: Generic Syntax by T. Berners-Lee, R. Fielding, and L. Masinter, August 1998.

RFC 2368: “The mailto URL scheme”, by P.Hoffman , L Masinter, J. Zwinski, July 1998.

RFC 1808: “Relative Uniform Resource Locators”, by R. Fielding, UC Irvine, June 1995.

RFC 1738: “Uniform Resource Locators (URL)” by T. Berners-Lee, L. Masinter, M. McCahill, December 1994

RFC 3986 is considered the current standard and any future changes to urlparse module should conform with it. The urlparse module is currently not entirely compliant with this RFC due to defacto scenarios for parsing, and for backward compatibility purposes, some parsing quirks from older RFCs are retained. The testcases in test_urlparse.py provides a good indicator of parsing behavior.

Functions

clear_cache() Clear the parse cache.
namedtuple(typename, field_names[, verbose, ...]) Returns a new subclass of tuple with named fields.
parse_qs(qs[, keep_blank_values, strict_parsing]) Parse a query given as a string argument.
parse_qsl(qs[, keep_blank_values, ...]) Parse a query given as a string argument.
unquote(() -> .)
urldefrag(url) Removes any existing fragment from URL.
urljoin(base, url[, allow_fragments]) Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.
urlparse(url[, scheme, allow_fragments]) Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
urlsplit(url[, scheme, allow_fragments]) Parse a URL into 5 components: <scheme>://<netloc>/<path>?<query>#<fragment> Return a 5-tuple: (scheme, netloc, path, query, fragment).
urlunparse(data) Put a parsed URL back together again.
urlunsplit(data) Combine the elements of a tuple as returned by urlsplit() into a complete URL as a string.

Classes

ParseResult
ResultMixin Shared methods for the parsed result objects.
SplitResult