首页 > 解决方案 > Can't login with python post错误出现

问题描述

当我尝试使用请求登录 GameStop(gamestop.ca) 时,这就是我得到的。我做错了什么或我错过了什么?我尝试添加许多其他标头,包括网络下 chrome dev 工具中显示的权限标头。我不明白为什么这不起作用,但是当我尝试使用 selenium 登录时 selenium 起作用。如果这是因为机器人检测,那么硒不应该更容易检测到吗?

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>

标签: pythonpython-requests

解决方案


推荐阅读