# Python requests calculate content length
In this section, we'll create a simple "content-length" calculate program in python. Let's follow the following steps and get content-length of your web page:
Step 1 : It is very important to install python requests module / package(eg : pip install requests).
pip install requests # for window
OR
pip3 install requests # for max, linux
Step 2 : After installing the request package, To verify the installation, you can try to import it like below:
import requests
Note : If you don't receive any errors importing the requests module, then it was successful installed.
Step 3 : Now, You can use 'GET request' to retrieve data from any destination
Let's create the simple example :
➤ Example : length.py
import requests
response = requests.get('https://www.google.com')
#Just take the len() of the content of the response:
content_len= len(response.content)
print(content_len)
Comments