【发布时间】:2022-11-24 03:54:31
【问题描述】:
我碰壁试图提出要求https://1stkissmanga.io/由于 CloudFlare 保护。我准备了标头和 cookie(我从 Firefox 读取)但仍然没有成功。奇怪的是,我可以使用 wget 正确获取此站点。这是我不明白的问题——wget 没有任何 CloudFlare 绕过机制,所以如果它在 wget 中工作,那么它不应该在 Python 请求中工作吗? 当然,对于 wget,我仍然需要提供 cookie 值,否则 wget 也会攻击 CloudFlare。 使用 wget(成功结果):
wget "https://1stkissmanga.io/" -U "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0" --header="Cookie: __cf_bm=<some long string with dots and other special characters>"
使用蟒蛇:
headers = {"user-agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0",} cookies = {"__cf_bm": "<some long string with dots and other special characters>",}
url = "https://1stkissmanga.io/" res = requests.get(url, headers=headers, cookies=cookies)
我也尝试将 cookie 放入标头中
headers = {"user-agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0", "cookie": "__cf_bm=<some long string with dots and other special characters>",}
并执行res = requests.get(url, headers=headers),但结果是一样的。无论我做什么,请求始终停止 CloudFlare 保护。
不确定下一步该怎么做,CloudFlare 代理暂时没有问题。
【问题讨论】:
标签: python cookies python-requests cloudflare