当前位置:首页 > python requests 请求https网站有警告InsecureRequestWarning: Unverified HTTPS request is being made to host 'xxx'.

python requests 请求https网站有警告InsecureRequestWarning: Unverified HTTPS request is being made to host 'xxx'.

点击次数:5237  更新日期:2020-10-28

requests 请求https网站,请求方式是加上verify=False 这个参数,如:


url="https://xxx.com"
r=requests.get(url,verify=False)


但这样会有如下的提示


C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py:979: InsecureRequestWarning: Unverified HTTPS request is being made to host 'xxx'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(


解决方法是在前面加上

requests.packages.urllib3.disable_warnings()