Python urllib Module
Example
Parse a URL into components:
from urllib.parse import urlparse
url = 'https://www.example.com/path?query=value'
parsed = urlparse(url)
print(f'Scheme: {parsed.scheme}')
print(f'Netloc: {parsed.netloc}')
print(f'Path: {parsed.path}')
Try it Yourself »
Definition and Usage
The urllib module is a package for working with URLs and making HTTP requests.
Use it to fetch web resources, parse URLs, encode data, or interact with web services.
Members
Member | Description |
---|---|
error | Submodule containing exception classes. |
parse | Submodule for parsing URLs. |
request | Submodule for opening and reading URLs. |
response | Submodule with response classes. |
robotparser | Submodule for parsing robots.txt files. |