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

可以看到,抓取的地址,評論人,評論內容,時間,產品顏色都已經抓取下來了。那么,爬取這些數據需要哪些工具呢?就兩個:
1. Chrome瀏覽器;
2. 插件:Web Scraper
插件下載地址:https://chromecj.com/productivity/2018-05/942.html
最后,如果你想自己動手抓取一下,這里是這次抓取的詳細過程:
1. 首先,復制如下的代碼,對,你不需要寫代碼,但是為了便於上手,復制代碼還是需要的,后續可以自己定制和選擇,不需要寫代碼。
{
"_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瀏覽器,在任意頁面同時按下Ctrl+Shift+i,在彈出的窗口中找到Web Scraper,如下:

3. 如下

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

5. 如圖,如果需要定制網址,注意替代一下,網址后面的#comment是直達評論的鏈接,不能去掉:

6. 如圖:

7. 如圖:

8. 如圖,點擊Scrape后,會自動運行打開需要抓取得頁面,不要關閉窗口,靜靜等待完成,完成后右下方會提示完成,一般1000條以內的評論不會有問題:

9. 最后,點擊下載到電腦,數據保存好。

使用這個工具的好處是:
1. 不需要編程;
2. 京東的評論基本可以通用此腳本,修改對應的url即可;
3. 如果需要爬取的評論不到1000條,這個工具會非常稱手,所有的數據完全自動下載;
使用的注意點:
1. 抓取過一次的數據會有記錄,立刻再次抓取將不會保存,建議關閉瀏覽器重新打開后再試;
2. 抓取數量:1000條以內沒有問題,可能是京東按照IP直接阻止了更多的爬取;
如果你的英語水平不錯,可以嘗試閱讀官方文檔,進一步學習和定制自己的爬蟲。
官方教程:https://www.webscraper.io/documentation
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持。