python爬蟲天貓商品資料

來源:互聯網
上載者:User
採用selenium類比瀏覽器抓取天貓紅酒銷售和價格資料,主要解決了以下幾個問題 1、採用selenium時爬蟲效率問題,這裡禁止了載入圖片和載入javascript,代碼如下
# 擷取瀏覽器驅動(禁止載入圖片和javascript)options = webdriver.ChromeOptions()pref = {'profile.default_content_setting_values': {'images': 2, 'javascript': 2}}options.add_experimental_option('prefs', pref)browser = webdriver.Chrome(chrome_options=options)browser_wait = WebDriverWait(browser, 10)
2、BeautifulSoup解析網頁  BeautifulSoup解析網頁代碼簡單,運用find()和find_all()能基本解決部分問題,但是解析效率不夠。
3、寫入本機資料庫  這裡採用自己封裝的mysqlhelper類,直接寫入本地mysql資料庫,效率一般 未解決的問題: 1、未解決商品詳情頁的評論資料抓取,未解決響應碼302 2、自己搭建的免費代理池品質不高,反扒效率不好 3、寫入mysql效率很差,原因暫時未知 4、附上自己的github連結:https://github.com/PandaHero/KNN-Algorithm/tree/master/tmall  






聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.