久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

瀏覽:4日期:2022-07-21 18:36:06

做電商時(shí),消費(fèi)者對(duì)商品的評(píng)論是很重要的,但是不會(huì)寫代碼怎么辦?這里有個(gè)Chrome插件可以做到簡單的數(shù)據(jù)爬取,一句代碼都不用寫。下面給大家展示部分抓取后的數(shù)據(jù):

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

可以看到,抓取的地址,評(píng)論人,評(píng)論內(nèi)容,時(shí)間,產(chǎn)品顏色都已經(jīng)抓取下來了。那么,爬取這些數(shù)據(jù)需要哪些工具呢?就兩個(gè):

1. Chrome瀏覽器;

2. 插件:Web Scraper

插件下載地址:https://chromecj.com/productivity/2018-05/942.html

最后,如果你想自己動(dòng)手抓取一下,這里是這次抓取的詳細(xì)過程:

1. 首先,復(fù)制如下的代碼,對(duì),你不需要寫代碼,但是為了便于上手,復(fù)制代碼還是需要的,后續(xù)可以自己定制和選擇,不需要寫代碼。

{ '_id': 'jdreview', 'startUrl': [ 'https://item.jd.com/100000680365.html#comment' ], 'selectors': [ { 'id': 'user', 'type': 'SelectorText', 'selector': 'div.user-info', 'parentSelectors': ['main' ], 'multiple': false, 'regex': '', 'delay': 0 }, { 'id': 'comments', 'type': 'SelectorText', 'selector': 'div.comment-column > p.comment-con', 'parentSelectors': ['main' ], 'multiple': false, 'regex': '', 'delay': 0 }, { 'id': 'time', 'type': 'SelectorText', 'selector': 'div.comment-message:nth-of-type(5) span:nth-of-type(4), div.order-info span:nth-of-type(4)', 'parentSelectors': ['main' ], 'multiple': false, 'regex': '', 'delay': '0' }, { 'id': 'color', 'type': 'SelectorText', 'selector': 'div.order-info span:nth-of-type(1)', 'parentSelectors': ['main' ], 'multiple': false, 'regex': '', 'delay': 0 }, { 'id': 'main', 'type': 'SelectorElementClick', 'selector': 'div.comment-item', 'parentSelectors': ['_root' ], 'multiple': true, 'delay': '10000', 'clickElementSelector': 'div.com-table-footer a.ui-pager-next', 'clickType': 'clickMore', 'discardInitialElements': false, 'clickElementUniquenessType': 'uniqueHTMLText' } ]}

2. 然后打開chrome瀏覽器,在任意頁面同時(shí)按下Ctrl+Shift+i,在彈出的窗口中找到Web Scraper,如下:

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

3. 如下

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

4. 如圖,粘貼上述的代碼:

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

5. 如圖,如果需要定制網(wǎng)址,注意替代一下,網(wǎng)址后面的#comment是直達(dá)評(píng)論的鏈接,不能去掉:

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

6. 如圖:

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

7. 如圖:

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

8. 如圖,點(diǎn)擊Scrape后,會(huì)自動(dòng)運(yùn)行打開需要抓取得頁面,不要關(guān)閉窗口,靜靜等待完成,完成后右下方會(huì)提示完成,一般1000條以內(nèi)的評(píng)論不會(huì)有問題:

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

9. 最后,點(diǎn)擊下載到電腦,數(shù)據(jù)保存好。

Python使用Chrome插件實(shí)現(xiàn)爬蟲過程圖解

使用這個(gè)工具的好處是:

1. 不需要編程;

2. 京東的評(píng)論基本可以通用此腳本,修改對(duì)應(yīng)的url即可;

3. 如果需要爬取的評(píng)論不到1000條,這個(gè)工具會(huì)非常稱手,所有的數(shù)據(jù)完全自動(dòng)下載;

使用的注意點(diǎn):

1. 抓取過一次的數(shù)據(jù)會(huì)有記錄,立刻再次抓取將不會(huì)保存,建議關(guān)閉瀏覽器重新打開后再試;

2. 抓取數(shù)量:1000條以內(nèi)沒有問題,可能是京東按照IP直接阻止了更多的爬取;

如果你的英語水平不錯(cuò),可以嘗試閱讀官方文檔,進(jìn)一步學(xué)習(xí)和定制自己的爬蟲。

官方教程:https://www.webscraper.io/documentation

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 平谷区| 青田县| 崇明县| 镇平县| 汕尾市| 满城县| 衡山县| 措勤县| 休宁县| 仙游县| 武宣县| 绥江县| 德保县| 新郑市| 新河县| 嘉义市| 临汾市| 靖宇县| 琼结县| 淮滨县| 寻乌县| 敦煌市| 洞头县| 巫溪县| 乌鲁木齐市| 永城市| 林芝县| 都昌县| 吐鲁番市| 朝阳市| 金阳县| 双鸭山市| 阿合奇县| 永平县| 江源县| 类乌齐县| 平陆县| 藁城市| 桐梓县| 陆川县| 丰县|