demo_requests_get_headers.py:
import requests url = 'https://begtut.com/try/demopage.html' #use the 'headers' parameter to set the HTTP headers: x = requests.get(url, headers = {"HTTP_HOST": "MyVeryOwnHost"}) print(x.text) #the 'demopage.html' prints all HTTP Headers
➜ begtut>python demo_requests_get_headers.py
HTTP_CONNECTION:keep-alive
HTTP_ACCEPT:*/*
HTTP_ACCEPT_ENCODING:gzip, deflate
HTTP_HOST:MyVeryOwnHost
HTTP_USER_AGENT:python-requests/2.22.0