我正在尝试使用python脚本访问和获取来自www.cclonline.com网站的数据。这就是代码。
import requests
from requests_html import HTML
source = requests.get('https://www.cclonline.com/category/409/PC-Components/Graphics-Cards/')
html = HTML(html=source.text)
print(source.status_code)
print(html.text)
这是我得到的错误,
403
Access denied | www.cclonline.com used Cloudflare to restrict access
Please enable cookies.
Error 1020
Ray ID: 64c0c2f1ccb5d781 • 2021-05-08 06:51:46 UTC
Access denied
What happened?
This website is using a security service to protect itself from online attacks.
我该如何解决这个问题?谢谢。
发布于 2021-11-16 09:52:47
我在抓取一个电子商务网站时遇到了同样的问题。显然,CloudFlare会分析请求的TLS指纹,并抛出403 (1020)代码,以防指纹与通常用于抓取的node.js/python/curl匹配。解决方案是模仿一些流行浏览器的指纹--最明显的方法是在puppeteer extra stealth plugin中使用Puppeteer.js。但是..。由于Puppeteer对于我的用例来说还不够快(我说得比较温和..我不得不构建一个类似curl的实用程序,它使用boringSSL -由于编译C/C++代码并找出一些TLS库的隐秘编译错误对于大多数web开发人员来说并不有趣--我将它包装为一个应用程序接口服务器,您可以在这里尝试:https://rapidapi.com/restyler/api/scrapeninja
https://stackoverflow.com/questions/67444887
复制相似问题