Advanced Lesson 2
HTTP Requests
Chapter 2: HTTP
requests
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 requestsurllib.request
: High levelrequests
: 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