Parse a URL into 6 components: :// / ; ? # The result is a named 6-tuple with fields corresponding to the above. It is either a ParseResult or ParseResultBytes object, depending on the type of the url parameter. The username, password,
(url, scheme='', allow_fragments=True)
| 372 | del _fix_result_transcoding |
| 373 | |
| 374 | def urlparse(url, scheme='', allow_fragments=True): |
| 375 | """Parse a URL into 6 components: |
| 376 | <scheme>://<netloc>/<path>;<params>?<query>#<fragment> |
| 377 | |
| 378 | The result is a named 6-tuple with fields corresponding to the |
| 379 | above. It is either a ParseResult or ParseResultBytes object, |
| 380 | depending on the type of the url parameter. |
| 381 | |
| 382 | The username, password, hostname, and port sub-components of netloc |
| 383 | can also be accessed as attributes of the returned object. |
| 384 | |
| 385 | The scheme argument provides the default value of the scheme |
| 386 | component when no scheme is found in url. |
| 387 | |
| 388 | If allow_fragments is False, no attempt is made to separate the |
| 389 | fragment component from the previous component, which can be either |
| 390 | path or query. |
| 391 | |
| 392 | Note that % escapes are not expanded. |
| 393 | """ |
| 394 | url, scheme, _coerce_result = _coerce_args(url, scheme) |
| 395 | scheme, netloc, url, params, query, fragment = _urlparse(url, scheme, allow_fragments) |
| 396 | result = ParseResult(scheme or '', netloc or '', url, params or '', query or '', fragment or '') |
| 397 | return _coerce_result(result) |
| 398 | |
| 399 | def _urlparse(url, scheme=None, allow_fragments=True): |
| 400 | scheme, netloc, url, query, fragment = _urlsplit(url, scheme, allow_fragments) |