How to get HTTP request headers with requests library in Python

1 Answer

0 votes
# pip install -U requests

import requests

url = 'https://www.allonpage.com/'
r = requests.get(url)

print(r.request.headers)


'''
run:
 
{'User-Agent': 'python-requests/2.20.1', 'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate', 'Connection': 'keep-alive'}

'''

 



answered Nov 19, 2018 by avibootz

Related questions

...