selenium保存cookie

selenium利用浏览器保存cookie

def make_cookie(item):
    return http.cookiejar.Cookie(
        version=0,
        name=item['name'],
        value=item['value'],
        port=None,
        port_specified=False,
        domain="jd.com",
        domain_specified=True,
        domain_initial_dot=False,
        path="/",
        path_specified=True,
        secure=False,
        expires=None,
        discard=False,
        comment=None,
        comment_url=None,
        rest=None
    )

scookie = driver.get_cookies()
for item in scookie:
    cookie.set_cookie(make_cookie(item))
with open("cookies.txt", "w") as fp:
    json.dump(scookie, fp)
driver.close()

未经允许不得转载:YiEcho博客 » selenium保存cookie

赞 (0) 打赏

相关推荐

    暂无内容!

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏