V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
vagrantear
V2EX  ›  Python

selenium 怎么实现通过添加 cookie 免登录

  •  
  •   vagrantear · 2020-04-28 12:40:03 +08:00 · 3753 次点击
    这是一个创建于 1430 天前的主题,其中的信息可能已经有所发展或是发生改变。
    同标题
    9 条回复    2020-04-30 17:45:57 +08:00
    yaoye555
        1
    yaoye555  
       2020-04-28 14:44:03 +08:00
    善用搜索
    vagrantear
        2
    vagrantear  
    OP
       2020-04-28 14:50:34 +08:00
    道理我都懂,我查出来的方法都失效了,我才来提问的 :)
    zcxey2911
        3
    zcxey2911  
       2020-04-28 20:57:47 +08:00
    请使用 driver.add_cookie(cookie)
    vagrantear
        4
    vagrantear  
    OP
       2020-04-29 11:11:33 +08:00
    @zcxey2911 用了,我还特意用 selenium 抓了 cookie,f12 的 cookie 都试过,还是不行。
    aaronhua
        5
    aaronhua  
       2020-04-30 10:34:09 +08:00
    yyb123456789
        6
    yyb123456789  
       2020-04-30 14:50:27 +08:00
    driver.add_cookie(cookie) 请添加必要的参数,最后比照下可用的请求 Cookies 和不可用的差别,深度的自定义添加过程
    vagrantear
        7
    vagrantear  
    OP
       2020-04-30 16:42:36 +08:00
    @yyb123456789 有点云里雾里,请问下有这方面的资料可以借鉴吗
    vagrantear
        8
    vagrantear  
    OP
       2020-04-30 17:38:36 +08:00
    @aaronhua
    我是这样写的,已经提前用 selenium 获取过 cookie 了,存起来,后续再使用就没用了。
    vagrantear
        9
    vagrantear  
    OP
       2020-04-30 17:45:57 +08:00
    ”httponly 如果值为 True,则无法通过该方式登陆",是这个原因吗,难受了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1641 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:49 · PVG 00:49 · LAX 09:49 · JFK 12:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.