Python请求失败,无法建立新的连接错误10061

2024-10-01 15:48:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用提供给我的密钥访问api。这是密码。在

import requests
import json
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
urletf='https://someapi'
s = requests.Session()
s.verify = False
resp_mf = s.get(urletf, params={"key":"somekey" }, stream=True)
content = resp_mf.content

这给我的错误是:无法建立连接

enter image description here

当我在浏览器或邮递员中尝试URL时,我会得到响应。在

https://someapi?key=myKey

知道Python为什么会出错吗?我期待着json回来(如果有关系的话)谢谢你的帮助。在


Tags: keyhttpsimportapijsonpackages密钥content
1条回答
网友
1楼 · 发布于 2024-10-01 15:48:07

我的公司有一个代理,我不得不用它来访问api。在

这个代码有效。在

import requests
import json
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
proxies = {<someproxy>}
urletf='https://someapi'
s = requests.Session()
s.verify = False
resp_mf = s.get(urletf, params={"key":"somekey" },proxies=proxies, stream=True)
content = resp_mf.content

相关问题 更多 >

    热门问题