【发布时间】:2019-12-06 14:14:22
【问题描述】:
我正在尝试使用公司的 API 获取网页,它在 Postman 中完美运行,但是当我将 Postman 生成的代码放入 python 请求时,它返回不同的响应。
我设置了我的代理并添加了我的基本身份验证,但它仍然无法正常工作
url = "https://www.test.com/confluence/rest/api/content/<id>"
querystring = {"expand":"space,body.view,version,container"}
headers = {
'Content-Type': "application/json",
'Authorization': "****",
'User-Agent': "PostmanRuntime/7.15.2",
'Accept': "*/*",
'Cache-Control': "no-cache",
'Postman-Token': "****",
'Host': "www.test.com",
'Cookie': "****",
'Accept-Encoding': "gzip, deflate",
'Connection': "keep-alive",
'cache-control': "no-cache"
}
response = requests.request("GET", url, headers=headers, params=querystring, proxies=urllib.request.getproxies())
Postman 返回一个 JSON 响应,其中包含整个网页 + ID 和任何其他必要信息。 Python 返回嵌入此错误的 HTML 网页
JavaScript is either disabled in or not supported by the Web browser.
To continue logon, use a Web browser that supports JavaScript or enable JavaScript in your current browser.
【问题讨论】:
-
你能提供你正在使用的网址吗?
标签: python python-requests postman