178. Working with HTTP Headers
import requests
url = 'https://httpbin.org/get'
headers = {'User-Agent': 'my-app/1.0'}
response = requests.get(url, headers=headers)
print(response.text)import requests
url = 'https://httpbin.org/headers'
response = requests.get(url)
print("Response Headers:")
print(response.headers)import requests
url = 'https://httpbin.org/get'
headers = {
'User-Agent': 'my-app/1.0',
'Accept': 'application/json',
'Authorization': 'Bearer your_token_here'
}
response = requests.get(url, headers=headers)
print(response.text)Last updated