推荐学习书目
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 · Oct 17, 2016 · 2790 views
    This topic created in 3519 days ago, the information mentioned may be changed or developed.
    8 replies    2016-10-18 10:04:41 +08:00
    est
        1
    est  
       Oct 17, 2016
    你用 py 一行一行把 js 翻译写到 requests.cookies 里。
    stamaimer
        2
    stamaimer  
       Oct 17, 2016 via iPhone
    selenium
    tafee
        3
    tafee  
    OP
       Oct 17, 2016
    @est 这种写法感觉比较费时,考虑用 splinter 直接调 chrome 登陆,再爬数据,不知道这样会不会方便点。。。
    tafee
        4
    tafee  
    OP
       Oct 17, 2016
    @stamaimer 恩,我也是想到了这个方法。
    ty89
        5
    ty89  
       Oct 17, 2016
    @tafee 你这样坑只会更多
    tafee
        6
    tafee  
    OP
       Oct 17, 2016
    @ty89 那还有其他途径么
    ty89
        7
    ty89  
       Oct 17, 2016
    老老实实用正则把 cookie 值解析出来交给 requests 处理吧.
    BiggerLonger
        8
    BiggerLonger  
       Oct 18, 2016 via Android
    應該在請求的 header 設置 Cookie:xxx 吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2897 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 69ms · UTC 14:22 · PVG 22:22 · LAX 07:22 · JFK 10:22
    ♥ Do have faith in what you're doing.