POST请求给出了错误,但我给出了所有的标题和表格D

2024-09-30 16:30:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图刮一个网站,一个登录表被要求;我使用的是requestspython3.x模块。我提供表单数据和标题信息,就像我可以在网络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>

以下是网络分析:Response 这是授权问题吗?或者这与我如何配置请求有关

谢谢你们:)


Tags: thehttpsformcomdatarequesthtmltype