How do I load session and cookies from Selenium browser to requests library in Python?
First you have to get the cookies from your driver instance:
cookies = driver.get_cookies()
This returns cookie dictionaries for your session.
Next, set those cookies in requests
:
s = requests.Session()
for cookie in cookies:
s.cookies.set(cookie['name'], cookie['value'])
You can use 3rd party package like selenium-requests or requestium. They provide function to share cookies between requests and selenium.