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

requests 的 SSL: CERTIFICATE_VERIFY_FAILED 問題

  •  
  •   squallcx · 2015-04-10 17:32:25 +08:00 · 8098 次点击
    这是一个创建于 3311 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

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

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

    第 1 条附言  ·  2015-04-11 08:06:15 +08:00
    改成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 条回复    2015-04-11 06:02:10 +08:00
    Livid
        1
    Livid  
    MOD
       2015-04-10 17:43:53 +08:00
    如果不影响功能的话,把 verify 设置成 False 试试?
    ljcarsenal
        2
    ljcarsenal  
       2015-04-11 00:04:41 +08:00
    楼上正解。。。
    ryd994
        3
    ryd994  
       2015-04-11 06:02:10 +08:00 via Android
    检查CA,有可能CA证书更新了
    浏览器因为自动更新所以没事
    简单解法就是不验证,有特别要求的话就指定CA
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   768 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 20:47 · PVG 04:47 · LAX 13:47 · JFK 16:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.