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

python 爬虫模拟用户登陆时, server 返回的 js 中写的 document.cookie 该如何模拟?求大神指导。

  •  
  •   tafee · 2016-10-17 16:58:48 +08:00 · 2159 次点击
    这是一个创建于 2749 天前的主题,其中的信息可能已经有所发展或是发生改变。
    8 条回复    2016-10-18 10:04:41 +08:00
    est
        1
    est  
       2016-10-17 17:00:43 +08:00
    你用 py 一行一行把 js 翻译写到 requests.cookies 里。
    stamaimer
        2
    stamaimer  
       2016-10-17 17:07:52 +08:00 via iPhone
    selenium
    tafee
        3
    tafee  
    OP
       2016-10-17 17:10:50 +08:00
    @est 这种写法感觉比较费时,考虑用 splinter 直接调 chrome 登陆,再爬数据,不知道这样会不会方便点。。。
    tafee
        4
    tafee  
    OP
       2016-10-17 17:11:34 +08:00
    @stamaimer 恩,我也是想到了这个方法。
    ty89
        5
    ty89  
       2016-10-17 17:11:45 +08:00
    @tafee 你这样坑只会更多
    tafee
        6
    tafee  
    OP
       2016-10-17 17:13:43 +08:00
    @ty89 那还有其他途径么
    ty89
        7
    ty89  
       2016-10-17 17:18:39 +08:00
    老老实实用正则把 cookie 值解析出来交给 requests 处理吧.
    BiggerLonger
        8
    BiggerLonger  
       2016-10-18 10:04:41 +08:00 via Android
    應該在請求的 header 設置 Cookie:xxx 吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1001 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 18:57 · PVG 02:57 · LAX 11:57 · JFK 14:57
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.