Building an HTTP client with urllib.request
The urllib.request
package is the recommended Python standard library package for HTTP tasks. The urllib
package has a simple interface and it has the capacity to manage all tasks related to HTTP requests.
Introducing the HTTP protocol
HTTP is an application layer protocol that defines the rules that clients, proxies, and servers need to follow for information exchange. It consists of two elements:
- A request made by the client to a specific resource on a remote server, specified by a URL
- A response sent by the server that supplies the resource the client requested
The HTTP protocol is a stateless protocol that does not store the exchanged information between client and server. Being a stateless protocol for storing information during an HTTP transaction, it is necessary to resort to other techniques for storing data. The most common approaches are cookies (values stored on the client side) or sessions (temporary...