Skip to main content
The urllib package provides modules for working with URLs.

Module Import

Making Requests

urlopen() - Open URL

Request with Headers

POST Request

URL Parsing

urlparse() - Parse URL

urlencode() - Encode Parameters

urljoin() - Join URLs

Error Handling

Downloading Files

Query String Parsing

Practical Examples

Simple API Client

Download with Progress

For modern HTTP client functionality, consider using the requests library instead of urllib.

http

HTTP modules

socket

Low-level networking

json

JSON encoding/decoding