关于python使用代理连接外网报错OSError: [Errno 0] Error

import requests

proxies = {

# "http": "http://63.161.104.189:3128",
# "https": "http://63.161.104.189:3128",
"http": "http://127.0.0.1:7890",
"https": "https://127.0.0.1:7890",

}
s = requests.get("https://www.google.com/", proxies=proxies)

print(s.text)

我们检查自己的代码,没有问题。我们访问国内的网站也没有问题。
访问外网,就会报错OSError: [Errno 0] Error。

这是服务器代理本身的错误给我们带来的不便,我们使用的是pip3,urllib3 本身存在的错误。 解决方法: 方法一:降低版本 把pip3 改成20.3之前的版本 方法二:修改参数
proxies = {

"http": "http://127.0.0.1:7890",
"https": "https://127.0.0.1:7890",

}
里面的的"https": "https://127.0.0.1:7890",改为"https": "http://127.0.0.1:7890"

来源:https://pythonmana.com/2021/02/20210208142815120D.html
posted @   yu-ye  阅读(2117)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
点击右上角即可分享
微信分享提示