【问题标题】:Python requests. 403 Forbidden despite copy headers from browser蟒蛇请求。 403 禁止,尽管从浏览器复制标头
【发布时间】:2023-01-29 22:15:02
【问题描述】:

我想访问带有 python 请求的站点,但尽管我复制了浏览器的标头并使用了它,但我还是收到 403 错误。这是我的代码,有没有人可以解决这个问题?

import requests

Url = 'https://bama.ir/'

session = requests.Session()

headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:98.0) Gecko/20100101 Firefox/98.0',
    'Accept-Language': 'en-US,en;q=0.5',
    'Upgrade-Insecure-Requests': '1',
    'Sec-Fetch-Dest': 'document',
    'Sec-Fetch-Mode': 'navigate',
    'Sec-Fetch-Site': 'none',
    'Sec-Fetch-User': '?1',
    'Connection': 'keep-alive',
}
session.headers = headers

r = session.get(Url, headers=headers)

【问题讨论】:

    标签: python python-requests http-status-code-403


    【解决方案1】:

    似乎检测到了 python-requests。

    您可以尝试使用提供的答案 here

    【讨论】:

      猜你喜欢
      • 2017-12-18
      • 2012-11-23
      • 1970-01-01
      • 2014-04-26
      • 1970-01-01
      • 2014-10-31
      • 2016-11-24
      • 2012-02-03
      • 1970-01-01
      相关资源
      最近更新 更多