Import and Use Request Module In Python

Python requests module is used to make HTTP requests easily. It makes the HTTP requests very easy without detailed request parameters. In this tutorial, we will learn how to import the requests module and use it for HTTP requests.

Install requests Module

The requests module is provided via the PyPI repository and can be installed with the pip command like below.

python -m pip install requests

Import requests Module

In order to use the requests module it should be imported with the import statement like below.

import requests

Make HTTP Request with requests Module

The get() method of the requests module can be used to make HTTP request. If required extra parameters can be also provided. In the following example we will make an HTTP get request to the “”.

import requests

r = requests.get('')

The returned response can be displayed with the text attribute of the returned response.


Leave a Comment