python-requests - 仅在使用 python-requests 时从 Typeform API 获取 406 Not Acceptable
问题描述
Typeform“以 JSON 形式查看表单”(例如:https ://api.typeform.com/forms/rGVAYs No Authentiction Needed)API 端点406 Not Acceptable
在通过 pythonrequests
库连接时返回错误,但没有来自其他客户端。
python请求发送的请求头如下:
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: python-requests/2.21.0
解决方案
出于某种我不知道的原因,Typeform“以 JSON 形式查看表单”API 端点似乎拒绝来自 pythonrequests
库的请求(仅?),发送 HTTP 错误406 Not Acceptable
对此的解决方案是添加一个指定不同的标头User-Agent
,本质上是欺骗用户代理
import requests
header = {
"User-Agent": "Mozilla/5.0",
}
resp = requests.get("https://api.typeform.com/forms/rGVAYs", headers=header)
print (resp.content)
推荐阅读
- ios - 在 IOS 上,元素是“可见的”并被点击,即使它没有显示
- python - 按指定自定义顺序的列对熊猫数据框进行排序
- ios - 在 iOS 上运行的 Flutter 调试卡在“等待天文台端口”
- git - 为什么 aws 部署的应用程序没有从链接的 git 存储库中提取服务器上的更改
- windows - 电源外壳。管道命令和使用 Foreach-Object 之间的区别
- ionic-framework - ionic statusbar.styleDefault() 不适用于 andorid
- umbraco - 如何在 Umbraco 8 中使用媒体选择器?
- python - 如何找到组中日期时间对象列的秒数差异?
- java - 在方法中使用 split 函数添加了“\n”,但在运行脚本时不起作用。我可以得到一些输入吗
- selenium - Selenide 无法下载 PDF