python - POST 请求给出错误但我给出所有标题和表单数据
问题描述
我正在尝试抓取一个网站,要求提供登录表单;我正在使用requests
python 3.x 模块。我提供 form_data 和 headers 信息,就像我可以在 Network Google Chrome 开发者控制台上分析的一样:
Payload = {
'form_data': {
'login': 'MYLOGIN',
'password': 'MYPASSWORD'},
'headers': {
'Accept': '*/*',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Origin': 'https://tastyworks.com',
'Referer': 'https://tastyworks.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
},
'url': 'https://tastyworks.com'
}
post_response = requests.post(
Payload['url'], data=Payload['form_data'], headers=Payload['headers'])
当我想在 post_response
这里打印时,我得到的是:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
This distribution is not configured to allow the HTTP request method that was used for this request. The distribution supports only cachable requests.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: YZ_tAajXFCioe5_fh6sVX4A4aPA_kSICtzKf2pkT76sPPj2R_WiOJg==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
这是网络分析:响应 这是授权问题吗?或者这与我如何配置请求有关?
多谢你们 :)
解决方案
推荐阅读
- python - 我需要一个正则表达式来在两个标签 python 之间找到一个短语
- python - Python 多个列表循环仅在列表之一出现异常后继续
- svg - 我可以为 [tableValues] 上的每个值设置特定间距吗?
- r - R reactable - 更新单行
- powershell - Powershell - 遍历从文本文件中获取的数组项失败
- c++ - 通过 C/C++ (Embarcadero) 生成以太坊地址
- python - 有没有一种简单的方法可以在 Seaborn 的同一个 FacetGrid 上绘制两个分类图?
- asp.net - Angular 8 + asp.net webapi Azure Ad 隐式身份验证
- android - 在系统上下文中在 android 上安装 CA 证书
- delphi - 有没有办法退出被卡住的 Parallel.foreach 循环中的线程