首页 > 解决方案 > 如何发送表单数据的标题

问题描述

我正在尝试登录 Gamestop(gamestop.ca),但它不会让我如下所示。我尝试添加各种标头但没有运气:(..我只是想知道我在发送我的发布请求时是否添加了错误的数据..有人可以确认吗?网络下响应部分中网站的内容类型是:

内容类型:文本/html;字符集=utf-8

import requests
import json

headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'}
payload = {
    'UserName': '*****',
    'Password': '******',
    'RememberMe': 'false'
}
with requests.session() as s:
    r = s.post('https://www.gamestop.ca/Account/LogOn', headers=headers, data=payload)
print(r.status_code)
print(r.content)
print(r.text)
403
b'<HTML><HEAD>\n<TITLE>Access Denied</TITLE>\n</HEAD><BODY>\n<H1>Access Denied</H1>\n \nYou don\'t have permission to access "http&#58;&#47;&#47;www&#46;gamestop&#46;ca&#47;Account&#47;LogOn" on this server.<P>\nReference&#32;&#35;18&#46;70fd017&#46;1635453520&#46;211da9c5\n</BODY>\n</HTML>\n'
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http&#58;&#47;&#47;www&#46;gamestop&#46;ca&#47;Account&#47;LogOn" on this server.<P>
Reference&#32;&#35;18&#46;70fd017&#46;1635453520&#46;211da9c5
</BODY>
</HTML>

ps 我可以使用 selenium 登录,所以我认为该错误不是由机器人保护引起的。

标签: pythonpython-requests

解决方案


推荐阅读