Http
Python's standard library includes the `urllib` package for making HTTP requests. While third-party libraries like `requests` offer a more user-friendly API, understanding urllib is valuable for dependency-free scripting. The guide walks through Making GET Requests, Handling Responses, POST & Form Data, Error Handling, Authentication & Sessions. `urllib.request.urlopen(url)` sends a GET request and returns a response object. `response.read()` returns the body as bytes. Use `Request` objects for custom headers: `Request(url, headers={"User-Agent": "..."})`. Response objects provide `.status` (status code), `.headers` (case-insensitive dict), and `.read()` (body). Decode bytes with `.read().decode("utf-8")`. For JSON responses, use `json.loads(response.read())`. Pass `data=urlencode({"key": "value"}).encode()` to the `Request` or `urlopen` for POST requests. Set `Content-Type` header to `application/x-www-form-urlencoded`. For JSON APIs, encode data with `json.dumps()` and set appropriate headers. The guide is organized into 5 sections that build on each other, each pairing a prose explanation with runnable code. Related guides: builtins, string, list, dict, os.