【发布时间】:2018-10-20 09:02:21
【问题描述】:
我在 windows 和 python3 上工作。 我使用 requests 模块通过此代码访问网页 -
requests.get('https://github.com/')
然后我收到SSLError [SSL: CERTIFICATE VERIFY FAILED ] 错误。然后我用verify=False关闭了SSL证书检查的开关。
import requests
requests.get('https://github.com/', verify=False)
现在它正在浏览网站但返回警告。
Warning (from warnings module):
File "C:\Python27\lib\site-packages\urllib3\connectionpool.py", line 847
InsecureRequestWarning)
InsecureRequestWarning: Unverified HTTPS request is being made. Adding
certificate verification is strongly advised. See:
https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
<Response [200]>
现在我正在使用脚本,我不想向用户显示此警告。我有办法隐藏警告,但我不知道如何使用它。
warnings.simplefilter("ignore")
但这会忽略所有警告,我只想特别隐藏这个“InsecureRequestWarning”。请指导我如何做到这一点。
【问题讨论】:
标签: python-3.x request warnings