网址为“https://sb-content.pa.caesarsonline.com/content-service/api/v1/q/time-band-event-list?”。
我认为它使用 Cloudflare,这就是我遇到困难的原因,但我不确定这是否是唯一的问题。我不一定需要 Scrapy 中显示的解决方案,我已经尝试过 cfscrape 并且无法让它获得除 403 之外的任何响应。
最佳答案
您认为这是 cloudflare 阻止自动请求是正确的。
<title>Access denied | sb-content.pa.caesarsonline.com used Cloudflare to restrict access</title>
您可以使用“cloudscraper”库来尝试绕过此问题,但由于 cloudflare 会定期更改其检测方法,因此在库更新之前您最终可能会遇到麻烦。
云抓取刀库:https://pypi.org/project/cloudscraper/
示例:
import cloudscraper
scraper = cloudscraper.create_scraper()
response = scraper.get("https://sb-content.pa.caesarsonline.com/content-service/api/v1/q/time-band-event-list?").text
print(response)
输出:
{"data":{"timeBandEvents":[{"type":"LIVE","date":null,"competitionSummary":[],"events":[],"outrights":[]},{"type":"NEXT_TO_GO"........
关于python - 知道如何使用 scrapy 访问此网址吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66045176/