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

看板Python作者 (涼)時間3年前 (2020/07/08 23:34), 編輯推噓1(107)
留言8則, 3人參與, 3年前最新討論串1/1
各位大大好, 目前在爬蟲上遇到一些問題想請教大家. 環境: 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

07/09 01:42, 3年前 , 1F
近幾個月cfscrape沒辦法解現在的保護,可以用Selenium去
07/09 01:42, 1F

07/09 01:42, 3年前 , 2F
模擬完在把cookie給requests用,或是看對方網站是不是只
07/09 01:42, 2F

07/09 01:42, 3年前 , 3F
針對亞洲IP添加保護
07/09 01:42, 3F

07/09 01:43, 3年前 , 4F
cfscrape 可以在fork中看看,有時候會看見神人短暫解幾
07/09 01:43, 4F

07/09 01:43, 3年前 , 5F
天XDD
07/09 01:43, 5F

07/09 10:27, 3年前 , 6F
感謝大大回覆,那看來cfscrape滿不穩定的。。 我再試
07/09 10:27, 6F

07/09 10:27, 3年前 , 7F
看看您說的方式。
07/09 10:27, 7F

07/09 14:20, 3年前 , 8F
文章代碼(AID): #1V1UUG0U (Python)