The requests module
The requests
module allows its users to make and send HTTP request methods. In the applications that we will be considering, it is mainly used to make contact with the server of the web pages we want to extract data from and obtain the response for the server.
Note
According to the official documentation of the module, the use of Python 3 is highly recommended over Python 2 for requests
.
To install the module on your computer, run the following:
pip install requests
You should use this code if you are using pip
as your package manager. If, however, you are using Anaconda instead, simply use the following:
conda install requests
These commands should install requests
and any other required dependencies (idna
, certifi
, urllib3
, and so on) for you if your system does not have those already. After this, run import requests
in a Python interpreter to confirm that the module has been installed successfully.
Making a request in Python
Let's look at an example usage of the module. If...