V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
DrakeLeung
V2EX  ›  Python

用 Scrapy 爬知乎,验证码总是错误。

  •  
  •   DrakeLeung · Dec 6, 2014 · 8257 views
    This topic created in 4162 days ago, the information mentioned may be changed or developed.
    我已经获取了验证码图片的地址,然后显示来,并手动输入。

    但是验证码还是错误?为什么
    11 replies    2015-01-28 10:00:05 +08:00
    bohan
        1
    bohan  
       Dec 6, 2014
    肯定是提交的有问题啊
    DrakeLeung
        2
    DrakeLeung  
    OP
       Dec 6, 2014
    @bohan 我看过他的请求,他需要的field,我都传了。有没有可能是加密问题?
    22too
        3
    22too  
       Dec 6, 2014
    有可能是验证码加密,这个你真没辙,
    whywhywhy
        4
    whywhywhy  
       Dec 6, 2014
    是不是没处理cookie
    DrakeLeung
        5
    DrakeLeung  
    OP
       Dec 6, 2014
    @whywhywhy 怎么处理cookie?用了帐号密码还需要处理cookie吗
    bohan
        6
    bohan  
       Dec 6, 2014
    如果请求都一样,那有可能就是cookie的问题了
    onlyice
        7
    onlyice  
       Dec 7, 2014 via Android
    上代码?一起研究下
    lfyzjck
        8
    lfyzjck  
       Dec 9, 2014   ❤️ 1
    Scrapy应该能自动处理Cookie,每个请求应该都是带上Cookie的,可以开DEBUG看看。

    http://doc.scrapy.org/en/latest/topics/downloader-middleware.html#cookies-mw

    每次请求获取验证码接口的时候,服务端对应的『正确结果』都会被刷新,所以注意别在提交验证码前再次请求获取验证码
    DrakeLeung
        9
    DrakeLeung  
    OP
       Dec 9, 2014
    @lfyzjck 你说对了!!好棒!!但是怎样才能显示一个图片出来啊?我现在用的方法是: http://stackoverflow.com/questions/7391945/how-do-i-read-image-data-from-a-url-in-python

    但是这种方法就像你所说的,需要再次请求验证码。所以验证码和页面那个不一样了。

    所以,有没有其他方法读取HTML里的图片,并显示出来?
    DrakeLeung
        10
    DrakeLeung  
    OP
       Dec 9, 2014
    @onlyice 好啊。看我回复楼下的。
    reloop
        11
    reloop  
       Jan 28, 2015
    最后 , 问题是怎么解决的?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5379 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 79ms · UTC 08:00 · PVG 16:00 · LAX 01:00 · JFK 04:00
    ♥ Do have faith in what you're doing.