python - 无法在未获得响应 [500] 的情况下模拟浏览器 POST 请求。为什么?
问题描述
import requests
url = 'https://cmoffice.kenes.com/cmsearchableprogrammev15/conferencemanager/CM_W3_SearchableProgram/api/persionid/anonymous/type/normal/getfilteredsessions/conference/igcs19'
headers = {'accept': '*/*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
'content-type': 'application/json; charset=UTF-8',
'cookie': '_ga=GA1.2.471841928.1549896884; _gid=GA1.2.1479150813.1563120868; __RequestVerificationToken_L2NtU2VhcmNoYWJsZVByb2dyYW1tZVYxNQ2=t57HyXHVNBIm0HZ33v1WyG8hRa4j4RlDEOvFtEfPakPgH5AutBjAN5pSRHnBx_BpBhbMnH6R-tIhSdop_VMtLF-aY7XcXTRFt7vg5X46zgE1; _gat=1',
'origin': 'https://cmoffice.kenes.com',
'referer': 'https://cmoffice.kenes.com/cmsearchableprogrammeV15/conferencemanager/programme/personid/anonymous/igcs19/normal/b833d15f547f3cf698a5e922754684fa334885ed',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
'x-requested-with': 'XMLHttpRequest'}
response = requests.post(url, headers = headers)
print(response)
给出响应 [500]
但是,浏览器能够获得带有 status_code 200 的 json 响应
谁能阐明为什么以及如何解决这个问题?
解决方案
后端似乎有些不对劲。当您尝试向其发布时,它会返回 500,这实际上可能是诸如缺少配置或编程错误之类的东西。
如果我在浏览器中点击给定的 URL,我实际上会收到 405 'method not allowed' 错误。
推荐阅读
- python - 如何使用请求将 URL 中的日历选择作为标头发送?
- vba - 试图让 GridLines 在 Access ListBox 中显示
- python - Dash Plotly 图形线条在某些动画帧中消失
- javascript - 如何模拟 js-cookie 和 jwt-decode 以根据测试更新其值
- javascript - 遍历嵌套对象的程序解决方案
- mysql - 如何在 sql 中找到中位数(代码问题)
- gtk - Flatpak 上的 Wayland 错误“无法打开显示:”
- python - 在容器中找不到 python 但已安装
- r - 更正列中文本类型数据的最有效方法是什么?
- iteration - 解除投资组合的通用功能