Python的requests库访问HTTPS网站时提示警告解决方法

当我们使用requests库访问某些HTTPS网站时,会报出以下警告:

InsecureRequestWarning: Unverified HTTPS request is being made to host 'raw.githubusercontent.com'. Adding certificate verification is strongly advised.

怎么做呢?

                requests.packages.urllib3.disable_warnings()
                resp = requests.get(url, verify=False)

禁用警告,同时加上verify参数,即可。

禁止转载,如需转载请通过简信或评论联系作者。

推荐阅读更多精彩内容