python - 带有代理的 Python 请求导致 SSLError WRONG_VERSION_NUMBER
问题描述
我不能在 Python 中使用不同的代理。
我的代码:
import requests
proxies = {
"https":'https://154.16.202.22:3128',
"http":'http://154.16.202.22:3128'
}
r=requests.get('https://httpbin.org/ip', proxies=proxies)
print(r.json())
我得到的错误是:
.
.
.
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /ip (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1122)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
.
.
.
requests.exceptions.SSLError: HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /ip (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1122)')))
我执行了pip install requests
。
我执行了pip uninstall pyopenssl
,然后尝试pip install
使用旧版本的 pyopenssl 但它没有用。
为什么这不起作用?
解决方案
问题是由于最新的 urllib3 中的错误而发生的(我在 version 中发现了它1.26.3
)。尝试降级到1.23
via pip3 install urllib3==1.23
,它应该可以解决问题。
推荐阅读
- scala - 从地图序列创建 Spark 数据帧
- ios - 当前点大于其余点的图像的自定义页面控件不起作用
- css - CSS Grid自动调整每行的宽度
- ruby - 标头/有效负载中的 ruby rest-client 内容
- javascript - 谷歌翻译使用标志
- objective-c - Objective c UITextField 填充顶部,底部,左侧和右侧
- android - AsyncTask 中 SplashScreen 的动画序列不起作用
- angular - 每次我订阅某个数据库路径时,firebase Web 客户端都会下载数据吗?
- python - 将数据输入到 python tkinter scrolledtreeview
- vb.net - 识别在 VB.Net 中启动的进程,以便以后能够杀死它及其所有子进程