1

Good Morning. I am trying to transfer cookies from a requests.session to my chrome webdriver.

My code is the following:

import requests
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

s=requests.session()
scraper=cfscrape.create_scraper(sess=s)

header={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"}


dataz={"login[email]": "", #my login data
    "login[password]": ""}


x=scraper.get("https://bstn.com")


y=scraper.post("https://www.bstn.com/einloggen", headers=header, data=dataz, allow_redirects=False)

print(y.cookies._cookies) 


driver=webdriver.Chrome()

driver.add_cookie(y)

driver.get("https://bstn.com/")```

The error I get is the following:
  ```  raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Response is not JSON serializable```

I hope that someone can help me fixing this error. My result that I expect is that I can run the script and continue my session in the browser... Thanks a lot

rocket
  • 217
  • 5
  • 16
  • No it is not a duplicate of the other one, sorry! If anyone can still help me with this one, I appreciate your comments! – rocket Jan 29 '19 at 13:02
  • Just a quick oneliner should solve this, but this is still a duplicate. driver.add_cookie(session.cookies.get_dict()) – Attila Kis Jan 30 '19 at 09:38

0 Answers0