Python请求Https报错临时解决办法

Python 2016-05-21

>>> url = 'https://www.baidu.com' 
>>> import requests
>>> response = requests.get(url,verify=False)
/Library/Python/2.7/site-packages/requests-2.9.1-py2.7.egg/requests/packages/urllib3/connectionpool.py:791: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)

请求https的时候会报错

临时解决办法:在文件头加上requests.packages.urllib3.disable_warnings() 虽然有点粗暴,但是对于我这种初学者来说并不影响什么,以后如果需求更高了,可能就会觉得这样做不妥,当然谁有更优雅的办法也可以评论或私聊我qq934817794.

yinbi.png


本文由 Mosuan 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

已有 3 人抢先你了

  1. 我擦...去搜了一下...还为了这个撕逼了...https://github.com/kennethreitz/requests/issues/2214

  2. 为什么要加verify=False? 如果不加的话,就不会有这些问题了呀?

添加新评论