Name
urljoin
Synopsis
urljoin(base_url_string,relative_url_string)
Returns a URL string u, obtained by
joining relative_url_string, which may be
relative, with base_url_string. The
joining procedure that urljoin performs to obtain
its result u may be summarized as follows:
When either of the argument strings is empty,
uis the other argument.When
relative_url_stringexplicitly specifies a scheme different from that ofbase_url_string,uisrelative_url_string. Otherwise,u’s scheme is that ofbase_url_string.When the scheme does not allow relative URLs (e.g.,
mailto), orrelative_url_stringexplicitly specifies a location (even when it is the same as the location ofbase_url_string), all other components ofuare those ofrelative_url_string. Otherwise,u’s location is that ofbase_url_string.u’s path is obtained by joining the paths ofbase_url_stringandrelative_url_stringaccording to standard syntax for absolute and relative URL paths. For example:import urlparse urlparse.urljoin( 'http://somehost.com/some/path/here', '../other/path') # Result is: 'http://somehost.com/some/other/path'
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access