defines a standard interface processing parse the URL, the URL to achieve split, merge and conversion.
1.urlparse () url split
urlparse(urlstring,scheme=‘’,allow_ragments=True)
- scheme: default protocol, with no time if the url entry into force of the agreement;
- allow_fragments: whether to ignore the fragment, if ignored, will be resolved as part of the path, params, or the query.
The url split into 6 sections:
- scheme: the agreement;
- netloc: domain name;
- path: access path;
- params: parameters;
- query: query;
- fragment: Anchor
Results value tuples, available parameters or index.
Code:
operation result:
2.urlunparse () url merger
urlunparse ([scheme, netloc, path, params, query, frament])
- Accepted parameters iterables;
- The number must be six, otherwise an error
Code:
operation result:
3.urlsplit ()
And the urlparse () is similar to, but not part of a separate params split, merge into the path of params
4.urlunsplit ()
And urlunparse () is similar, the only difference between the parameters passed to five
5.urljoin ()
base_url as the first argument, the new connection as the second parameter, this method analyzes base_url in the scheme, netloc, path three parts, and the new link is indeed part be added.
If there is a new link in this three-part, how with the new link, without the use of base_url.
In the base_url params, query, fragment does not work.
6.urlencode()
Configuration is useful when the request parameters, the parameters of a dictionary, the sequence into url parameters available.
7.parse_qs()
And urlencode () On the contrary, the url parameter deserialize dictionary.
8.parse_qsl()
The url parameter into a list of tuples, the results as a list, each element of the tuple list.
9.quote()
The url parameter into the Chinese url encoding format parameters cause Chinese avoid distortion.
10.unquote()
And quote () Conversely