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, pa
(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 | splitresult = urlsplit(url, scheme, allow_fragments) |
| 396 | scheme, netloc, url, query, fragment = splitresult |
| 397 | if scheme in uses_params and ';' in url: |
| 398 | url, params = _splitparams(url) |
| 399 | else: |
| 400 | params = '' |
| 401 | result = ParseResult(scheme, netloc, url, params, query, fragment) |
| 402 | return _coerce_result(result) |
| 403 | |
| 404 | def _splitparams(url): |
| 405 | if '/' in url: |
no test coverage detected