python使用requests时报错requests.exceptions.SSLError: HTTPSConnectionPool

requests.exceptions.SSLError: HTTPSConnectionPool(host=‘www.baidu.com‘, port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, u‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)‘),))

错误提示就是上面这样的。首先我找了很多的资料,有很多人说关闭证书验证(verify=False))可以解决这个问题或者说是在进行GET时,指定SSL证书.

response = requests.get(‘http://www.baidu.com/‘, headers = header, verify=False)

但我用以上两种方法都没有完美解决此问题,而且有些还有后续错误比如InsecureRequestWarning

正确的做法参考文档资料

https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl

参考博客:http://blog.csdn.net/zahuopuboss/article/details/52964809

只要安装一下几个requests依赖包就可以解决此问题

pip install cryptography

pip install pyOpenSSL

pip install certifi

原文转至博客:https://blog.csdn.net/qq_31077649/article/details/79013199

原文地址:https://www.cnblogs.com/hum0ro/p/9536033.html

时间: 2024-10-09 06:53:27

python使用requests时报错requests.exceptions.SSLError: HTTPSConnectionPool的相关文章

解决python爬虫requests.exceptions.SSLError: HTTPSConnectionPool(host='XXX', port=443)问题

爬虫时报错如下: requests.exceptions.SSLError: HTTPSConnectionPool(host='某某某网站', port=443): Max retries exceeded with url: /login/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify fail

requests.exceptions.SSLError: HTTPSConnectionPool报错解决方案

运行脚本报错: Traceback (most recent call last): File "F:/Interface_Study/study_requests/auto_get_post.py", line 24, in <module> res = Calendar_Query().request_main(url,'get',data) File "F:/Interface_Study/study_requests/auto_get_post.py&qu

python 读取文件时报错UnicodeDecodeError: &#39;gbk&#39; codec can&#39;t decode byte 0x80 in position 205: illegal multibyte sequence

python读写txt文件转化成excel文件 python读取文件时提示"UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multibyte sequence" 解决办法1. FILE_OBJECT= open('order.log','r', encoding='UTF-8') 解决办法2. FILE_OBJECT= open('order.log','rb') pyth

python 脚本运行时报错: AttributeError: &#39;module&#39; object has no attribute ***

最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attribute 'xxx'".这其实是.pyc文件存在问题. 问题定位: 查看import库的源文件,发现源文件存在且没有错误,同时存在源文件的.pyc文件 问题解决方法: 1. 命名py脚本时,不要与python预留字,模块名等相同 2. 删除该库的.pyc文件(因为py脚本每次运行时均会生成.pyc文件

python 读取文件时报错: UnicodeDecodeError: &#39;gbk&#39; codec can&#39;t decode byte 0xa4 in position 127: illegal multibyte sequence

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 127: illegal multibyte sequence python读取文件时提示UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 127: illegal multibyte sequence 解决办法: FILE_OBJECT= open('order.log','r'

python 创建虚拟环境时报错OSError, setuptools下载失败

错误信息如下: Using base prefix 'c:\\users\\huful\\appdata\\local\\programs\\python\\python36-32'New python executable in E:\Learning\Python\search\Scripts\python.exeInstalling setuptools, pip, wheel... Complete output from command E:\Learning\Python\searc

python 访问网站时报错:requests.exceptions.SSLError: HTTPSConnectionPool

解决该错误的正确姿势是更新pyOpenSSL库.输入命令: 1 pip install pyopenssl 参见: https://github.com/requests/requests/issues/4246 原文地址:https://www.cnblogs.com/mcgill0217/p/10357003.html

打包python为可执行文件时报错R6034解决方案

R6034 指的是:"An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information". 网上的解决办法很多,但是比较乱,也没有介绍是在什么应用中发生的R6034问题. 今天给大家介绍一个,在运行Python时候遇到的R6034的解决办法. 方法转自 http:/

requests.exceptions.SSLError……Max retries exceeded with url错误求助!!!

import requests head = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36", "Connection": "close"} html = requests.get("https://fa