Unable to add a cookie using Selenium & Splinter

后端 未结 2 1817
青春惊慌失措
青春惊慌失措 2021-01-07 04:30

Per below, I\'m not sure how to troubleshoot this pretty simple usage scenario.

I have script (that I run about once a month) that functionally does the identical th

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-07 04:54

    you should open the url first, and load the cookies, then you can open the next url with cookies.you can also open like that if you want open the same url:

    driver = webdriver.Chrome(executable_path=r'X:\home\xxx\chromedriver.exe')
    
    cookies = pickle.load(open("cookies.pkl", "rb"))
    driver.get("https://www.douban.com/")
    for cookie in cookies:
        driver.add_cookie(cookie)
    driver.get("https://www.douban.com/")
    

    hope this helps

提交回复
热议问题