推荐学习书目
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
tianxin8431
V2EX  ›  Python

python 无法获取 cookie

  •  
  •   tianxin8431 · May 30, 2015 · 4614 views
    This topic created in 4004 days ago, the information mentioned may be changed or developed.

    如题,最近学python,尝试做一个爬虫工具,但是使用cookielib.CookieJar()获取不到cookie,header也加上了,求解。爬的网站是http://czyw.cooco.net.cn

    8 replies    2015-06-01 11:35:34 +08:00
    ChanneW
        1
    ChanneW  
       May 30, 2015
    是有cookies的,但是网站不要求登录,你记cookies有啥用。
    tianxin8431
        2
    tianxin8431  
    OP
       May 30, 2015
    @ChanneW 这个脚本的目的是为了自动扒题..然后那个网站是通过cookie来记录题目的编号的
    sivacohan
        3
    sivacohan  
    PRO
       May 30, 2015 via Android
    你看一下cookie是哪个URL种的。
    tianxin8431
        4
    tianxin8431  
    OP
       May 30, 2015
    @sivacohan 试过了,还是不行。另外我测试的时候发现一个问题,用python请求163,qq等时也获取不到cookie,只有测试百度时候有。
    Chichele
        5
    Chichele  
       May 30, 2015
    用requests
    wibile
        6
    wibile  
       May 30, 2015
    @tigerstudent +10086,requests session
    xixijun
        7
    xixijun  
       May 30, 2015
    我看了下是有cookie的啊

    Cookie: AJSTAT_ok_pages=3; AJSTAT_ok_times=1; Hm_lvt_c8ad39b9579b4816dc8f6f805c190308=1432993700; Hm_lpvt_c8ad39b9579b4816dc8f6f805c190308=1432994293; bdshare_firstime=1432993700351
    julyclyde
        8
    julyclyde  
       Jun 1, 2015
    cookielib我记得是处理cookie格式的字符串的吧,并不是处理http协议的cookie header的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2584 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 00:24 · PVG 08:24 · LAX 17:24 · JFK 20:24
    ♥ Do have faith in what you're doing.