首页 > 解决方案 > Python 使用请求登录网站返回 403

问题描述

我正在尝试使用. requests问题是网站返回 403 状态码。

这是我的代码:

import requests

url = 'https://www.zalando-lounge.com/onboarding-api/login'

payload = {
    'email': 'my_email',
    'password': 'my_password',
    'onlyLogin': 'true'
}

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0'
}

with requests.Session() as s:
    r = s.post(url, json=payload, headers=headers)
    print(r.status_code)
    print(r.text)

作为回应,我得到 403 状态码,这是:

<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http&#58;&#47;&#47;failover&#46;www&#46;zalando&#45;lounge&#46;de&#47;waf&#95;deny&#95;lounge&#46;html&#63;" on this server.<P>
Reference&#32;&#35;18&#46;379ec817&#46;1608234674&#46;21c18108
</BODY>
</HTML>

标签: pythonpython-3.xpython-requestshttp-status-code-403

解决方案


推荐阅读