How to save and load cookies using Python + Selenium WebDriver

后端 未结 6 614
孤街浪徒
孤街浪徒 2020-11-22 07:52

How can I save all cookies in Python\'s Selenium WebDriver to a txt-file, then load them later? The documentation doesn\'t say much of anything about the getCookies function

6条回答
  •  长情又很酷
    2020-11-22 08:42

    Remember, you can only a add cookie for the current domain. If you wanna add a cookie for your Google account, do

    browser.get('http://google.com')
    for cookie in cookies:
        browser.add_cookie(cookie)
    

提交回复
热议问题