【发布时间】:2022-12-18 04:20:43
【问题描述】:
我正在尝试访问支持 GET、POST、PUT、MOVE 函数的 Rest API。当我尝试使用浏览器的 URL 获取文件列表时,我收到了来自 REST API 的响应。但是,当我尝试通过 requests.get(url) 调用相同的 URL 时,我得到:
(由 ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x000002D8CCFBC6A0>, 'Connection to timed out. (connect timeout=None)'))
我错过了什么? (如果有什么不同,我将在 URL 中传递 JWT 令牌)
#URL 在浏览器中返回一个 JSON 格式的列表
#当通过请求调用相同的URL时
import requests
url = https://wwww.restapi.com/content?JWT-token
x = requests.get(url)
print(x.status_code)
#错误输出: (由 ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x000002D8CCFBC6A0>, 'Connection to <URL> timed out. (connect timeout=None)'))
【问题讨论】:
标签: python-3.x rest python-requests urllib