跟大家分享的是web scraper爬蟲工具使用方法刷后。
目錄
1.Web Scraper插件安裝
2.上手體驗(yàn)
3.抓取的基本步驟
4.規(guī)律多頁(yè)規(guī)則
5.下載數(shù)據(jù)
1兽赁、Web Scraper插件安裝:
Google瀏覽器擴(kuò)展程序中搜素“Web Scraper”安裝即可俭令。
2驻粟、上手體驗(yàn)
Web Scraper-->Creater New sitemap--> Import sitemap-->sitemap JSON 區(qū)域輸入神秘代碼-->輸入站點(diǎn)名(自定義)并導(dǎo)入友扰。
神秘代碼:
{"_id":"test","startUrl":"https://www.zhihu.com/people/chen-da-xin-84/followers?page=2","selectors":[{"parentSelectors":["_root"],"type":"SelectorText","multiple":true,"id":"Username","selector":"div.UserItem-title a.UserLink-link","regex":"","delay":"500"}]}
3役电、抓取的基本步驟
使用web scraper插件抓取的基本步驟為:
- 創(chuàng)建一個(gè)站點(diǎn)Create sitemap
- 新增選擇器Add new selector
- 點(diǎn)擊Scrape抓取
具體操作步驟如下:
步驟一:創(chuàng)建一個(gè)新的站點(diǎn)“Create sitemap”
打開控制臺(tái)—選擇web scraper插件—選擇Create new sitemap—選擇Create sitemap赚爵;
在Sitemap name中給站點(diǎn)地圖命名,在Start URL中輸入站點(diǎn)名(自定義)和網(wǎng)址(目標(biāo)地址)法瑟,點(diǎn)擊Create Sitemap按鈕冀膝,就創(chuàng)建好了一個(gè)站點(diǎn)地圖。
步驟二:增加選擇器霎挟,點(diǎn)擊“Add New selector”窝剖;
選擇器的配置:
1. Type選擇Text文本形
2.勾選Multiple按鈕,表示本頁(yè)中需要抓取多個(gè)元素
3.Delay填寫500
4.點(diǎn)擊Selector的select按鈕直接用鼠標(biāo)選網(wǎng)頁(yè)上的元素酥夭,絕色代碼可采集的數(shù)據(jù)赐纱,點(diǎn)擊后為紅色鎖定狀態(tài)
步驟三:點(diǎn)擊Scrape抓取
Request interval:請(qǐng)求間隔
Page load delay:頁(yè)面加載延遲
4脊奋、規(guī)律多頁(yè)規(guī)則
點(diǎn)擊“Edit metadata”,修改Start URL疙描。規(guī)律多頁(yè)Start URL這里可以寫成https://www.xxxx?page=[1-3]或https://www.xxxx?start=[0-5:10](表示0-5頁(yè)20條/頁(yè))诚隙。
5、下載數(shù)據(jù)
Export data as CSV