selenium 해결.common.exceptions.InvalidArgumentException: Message: invalid argument: invalid 'expiry'

1600 단어

브라우저에서 쿠키 추가

 with open('cookies', 'r', encoding='utf-8') as f:
        list_cookies = json.loads(f.readline())
        print(list_cookies)
        # cookie = [item["name"] + "=" + item["value"] for item in list_cookies]
        # cookiestr = '; '.join(item for item in cookie)
        # print(cookiestr)

        driver.get("https://jd.com")
        driver.delete_all_cookies()

        for cookie in list_cookies:
            driver.add_cookie(cookie)
        driver.get("https://order.jd.com/center/list.action")
        return driver

잘못하다

selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: invalid 'expiry'
  (Session info: chrome=77.0.3865.120)

해결 방법

with open('cookies', 'r', encoding='utf-8') as f:
        list_cookies = json.loads(f.readline())
        print(list_cookies)
        # cookie = [item["name"] + "=" + item["value"] for item in list_cookies]
        # cookiestr = '; '.join(item for item in cookie)
        # print(cookiestr)

        driver.get("https://jd.com")
        driver.delete_all_cookies()

        for cookie in list_cookies:
            if 'expiry' in cookie:
                del cookie['expiry']
            driver.add_cookie(cookie)
        driver.get("https://order.jd.com/center/list.action")
        return driver

좋은 웹페이지 즐겨찾기