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

requests 的 SSL: CERTIFICATE_VERIFY_FAILED 問題

  •  
  •   squallcx · Apr 10, 2015 · 8855 views
    This topic created in 4200 days ago, the information mentioned may be changed or developed.

    一直都在用requests来某一https抓取网页
    结果该网站今天突然无法抓取,出现如下讯息

    import requests
    r = requests.get('https://123456.com/', verify=True)
    [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed.
    

    换个IP试试代码就可以正常抓取,但访问几分钟之后又出现一样的讯息

    浏览器却一直都可以直接访问没问题

    Supplement 1  ·  Apr 11, 2015
    改成verify=False则是出现

    D:\Python27\lib\site-packages\requests-2.6.0-py2.7.egg\requests\packages\urllib3\connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib
    3.readthedocs.org/en/latest/security.html InsecureRequestWarning)
    3 replies  •  2015-04-11 06:02:10 +08:00
    Livid
        1
    Livid  
    MOD
    PRO
       Apr 10, 2015
    如果不影响功能的话,把 verify 设置成 False 试试?
    ljcarsenal
        2
    ljcarsenal  
       Apr 11, 2015
    楼上正解。。。
    ryd994
        3
    ryd994  
       Apr 11, 2015 via Android
    检查CA,有可能CA证书更新了
    浏览器因为自动更新所以没事
    简单解法就是不验证,有特别要求的话就指定CA
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3217 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 13:51 · PVG 21:51 · LAX 06:51 · JFK 09:51
    ♥ Do have faith in what you're doing.