如何在Scrapy中绕过cloudflare botddos​​保护?

如何在Scrapy中绕过cloudflare botddos​​保护?,第1张

如何在Scrapy中绕过cloudflare bot / ddos​​保护?

因此,我在cloudflare-scrape的帮助下使用Python执行了Javascript 。

在你的抓取中,你需要添加以下代码:

def start_requests(self):  for url in self.start_urls:    token, agent = cfscrape.get_tokens(url, 'Your prefarable user agent, _optional_')    yield Request(url=url, cookies=token, headers={'User-Agent': agent})

以及解析功能。就是这样!

当然,你需要先安装cloudflare-scrape并将其导入到Spider。你还需要安装JS执行引擎。我已经有了Node.JS,没有怨言。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/4890103.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-11

发表评论

登录后才能评论

评论列表(0条)

保存