[問題] [爬蟲] DDos protection by Cloudflare

作者: coolteac (涼)   2020-07-08 23:34:38
各位大大好,
目前在爬蟲上遇到一些問題想請教大家.
環境: 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?
感謝
作者: TakiDog (多奇狗)   2020-07-09 01:42:00
近幾個月cfscrape沒辦法解現在的保護,可以用Selenium去模擬完在把cookie給requests用,或是看對方網站是不是只針對亞洲IP添加保護cfscrape 可以在fork中看看,有時候會看見神人短暫解幾天XDD
作者: coolteac (涼)   2020-07-09 10:27:00
感謝大大回覆,那看來cfscrape滿不穩定的。。 我再試看看您說的方式。
作者: janice001 (真理)   2020-07-09 14:20:00

Links booklink

Contact Us: admin [ a t ] ucptt.com