Reputation: 1004
I am making a Python 3-script with Selenium 4 and Gecko web driver.
I am using cookies = driver.get_cookies()
to capture cookies after logging in to a site.
The question is how I can cookies from Selenium in a GET request using the Requests module. In other words, how can we capture cookies with Selenium and use those cookies in Requests?
I tried the suggested answer in this question, but it is not correct and the question is over a year old without any other answers...
Upvotes: 0
Views: 3695
Reputation: 2968
Try this way:
cookies = driver.get_cookies()
requests_cookies = {}
for c in cookies:
requests_cookies[c['name']] = c['value']
response = requests.get('http://some-host...', cookies=requests_cookies)
Reference:
Upvotes: 1