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
Lone2Ranger
V2EX  ›  Python

selenium 中 cookies 的处理

  •  
  •   Lone2Ranger · 2019-04-12 16:26:40 +08:00 · 1775 次点击
    这是一个创建于 1833 天前的主题,其中的信息可能已经有所发展或是发生改变。
    selenium cookies
    add_cookie(cookie_dict):添加 cookie。“ cookie_dict ”指字典对象,必须有 name 和 value 值。
    访问的网页中 F12 cookies 没有 直接的 name 和 value 那怎么选的 name value
    是 cookies 中的第一个 键值对吗
    求大佬解惑
    3 条回复    2019-04-12 20:37:17 +08:00
    lwtting
        1
    lwtting  
       2019-04-12 19:04:39 +08:00   ❤️ 1
    cookies = driver.get_cookies()
    realCookie = {}
    for elem in cookies:
    realCookie[elem['name']] = elem['value']
    yth492300648
        2
    yth492300648  
       2019-04-12 19:05:13 +08:00   ❤️ 1
    mark 下 也遇到了这个问题 希望能携带 cookie 登陆 不过 selenuim cookie 感觉不像 requests 好弄
    Lone2Ranger
        3
    Lone2Ranger  
    OP
       2019-04-12 20:37:17 +08:00
    好像用 webdriver.get()可以获取完整的 cookies
    在用得到的 cookies 拿来用
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5375 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 06:42 · PVG 14:42 · LAX 23:42 · JFK 02:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.