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=None, allow_fragments=True, *, missing_as_none=_MISSING_AS_NONE_DEFAULT)
| 445 | del _fix_result_transcoding |
| 446 | |
| 447 | def urlparse(url, scheme=None, allow_fragments=True, *, missing_as_none=_MISSING_AS_NONE_DEFAULT): |
| 448 | """Parse a URL into 6 components: |
| 449 | <scheme>://<netloc>/<path>;<params>?<query>#<fragment> |
| 450 | |
| 451 | The result is a named 6-tuple with fields corresponding to the |
| 452 | above. It is either a ParseResult or ParseResultBytes object, |
| 453 | depending on the type of the url parameter. |
| 454 | |
| 455 | The username, password, hostname, and port sub-components of netloc |
| 456 | can also be accessed as attributes of the returned object. |
| 457 | |
| 458 | The scheme argument provides the default value of the scheme |
| 459 | component when no scheme is found in url. |
| 460 | |
| 461 | If allow_fragments is False, no attempt is made to separate the |
| 462 | fragment component from the previous component, which can be either |
| 463 | path or query. |
| 464 | |
| 465 | Note that % escapes are not expanded. |
| 466 | |
| 467 | urlsplit() should generally be used instead of urlparse(). |
| 468 | """ |
| 469 | url, scheme, _coerce_result = _coerce_args(url, scheme) |
| 470 | if url is None: |
| 471 | url = '' |
| 472 | scheme, netloc, url, params, query, fragment = _urlparse(url, scheme, allow_fragments) |
| 473 | if not missing_as_none: |
| 474 | if scheme is None: scheme = '' |
| 475 | if netloc is None: netloc = '' |
| 476 | if params is None: params = '' |
| 477 | if query is None: query = '' |
| 478 | if fragment is None: fragment = '' |
| 479 | result = ParseResult(scheme, netloc, url, params, query, fragment) |
| 480 | result = _coerce_result(result) |
| 481 | result._keep_empty = missing_as_none |
| 482 | return result |
| 483 | |
| 484 | def _urlparse(url, scheme=None, allow_fragments=True): |
| 485 | scheme, netloc, url, query, fragment = _urlsplit(url, scheme, allow_fragments) |
searching dependent graphs…