作者coolteac (凉)
看板Python
标题[问题] [爬虫] DDos protection by Cloudflare
时间Wed Jul 8 23:34:38 2020
各位大大好,
目前在爬虫上遇到一些问题想请教大家.
环境: windows 10, python 3.8.3, nodejs v12.18.2, cfscrape v2.1.1
因为爬
https://www.wantgoo.com/stock/astock/techchart?stockno=8069 时,
会出现 DDos protection by Cloudflare, 所以有google 找到可以使用 cfscrape
来解决, 但使用 cfscrape的范例:
import cfscrape
scraper = cfscrape.create_scraper() # returns a CloudflareScraper instance
# Or: scraper = cfscrape.CloudflareScraper() # CloudflareScraper inherits
from requests.Session
print scraper.get("
https://www.wantgoo.com/stock/2892").content # =>
"<!DOCTYPE html><html><head>..."
执行时会在 scraper.get 那一行出现以下 error:
ValueError: Unable to identify Cloudflare IUAM Javascript on website.
Cloudflare may have changed their technique, or there may be a bug in the
script.
想请教大家是否知道可以怎麽解决? 或是不使用 cfscrape 可以解决 Cloudflare?
感谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 123.195.4.56 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1594222480.A.01E.html
1F:→ TakiDog: 近几个月cfscrape没办法解现在的保护,可以用Selenium去 07/09 01:42
2F:→ TakiDog: 模拟完在把cookie给requests用,或是看对方网站是不是只 07/09 01:42
3F:→ TakiDog: 针对亚洲IP添加保护 07/09 01:42
4F:→ TakiDog: cfscrape 可以在fork中看看,有时候会看见神人短暂解几 07/09 01:43
5F:→ TakiDog: 天XDD 07/09 01:43
6F:→ coolteac: 感谢大大回覆,那看来cfscrape满不稳定的。。 我再试 07/09 10:27
7F:→ coolteac: 看看您说的方式。 07/09 10:27