作者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://www.ptt.cc/bbs/Python/M.1594222480.A.01E.html
→ TakiDog: 近幾個月cfscrape沒辦法解現在的保護,可以用Selenium去 07/09 01:42
→ TakiDog: 模擬完在把cookie給requests用,或是看對方網站是不是只 07/09 01:42
→ TakiDog: 針對亞洲IP添加保護 07/09 01:42
→ TakiDog: cfscrape 可以在fork中看看,有時候會看見神人短暫解幾 07/09 01:43
→ TakiDog: 天XDD 07/09 01:43
→ coolteac: 感謝大大回覆,那看來cfscrape滿不穩定的。。 我再試 07/09 10:27
→ coolteac: 看看您說的方式。 07/09 10:27