我正在尝试抓取网站,要求输入登录表单;我正在使用requests
python 3.x模块。我提供form_data和标头信息,就像我可以在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>
以下是网络分析:Response 这是授权问题吗?还是这与我配置请求的方式有关?
谢谢大家:)