This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 2: HTTP

requests

face Josiah Wang

Now, let’s try to send an HTTP request to a server and receive an HTTP response from the server!

There are many Python modules/packages that you can use to make HTTP requests, each at a different level of abstraction.

  • http.client: For low level requests
  • urllib.request: High level
  • requests: An external package, very high-level, “built for human beings” according to their page.

We will use the requests package for this lesson, as it is simple and makes sending HTTP requests and receiving responses easy without needing to worry about the low-level details.

As requests is an external package, you should install it via pip install requests.

You will then need to import it as usual.

>>> import requests