import requests
session = requests.Session()
url = 'https://httpbin.org/headers'
access_token = {
'Authorization': 'Bearer {access_token}'
}
session.headers.update(access_token)
response1 = session.get(url)
response2 = session.get(url)
print('response1: ', response1.json()['headers']['Authorization'])
print('response2: ', response2.json()['headers']['Authorization'])
with requests.Session() as s:
s.get('https://httpbin.org/cookies/set/sessioncookie/123456789')
# Creating a Session in python using requests
>>> from requests_html import HTMLSession
>>> session = HTMLSession()
>>> r = session.get('https://python.org/')