DataScraper數據抓取快速入門

1.首先學習採集器的基本使用方法

可參考以下幾篇文章:

網站採集器MetaSeeker v4.x速成手冊:http://www.gooseeker.com/cn/node/document/metaseeker/cookbookv4/bookfront.html

案例:如何規劃網站數據採集:

http://www.gooseeker.com/cn/node/Fulelr/2009120501

卓越網商品數據分級抓取:

http://www.gooseeker.com/cn/node/document/metaseeker/cookbookv4/multilayers.html

2.縮小抓取對象

由於我們不是每種產品都需要抓取,所以對需要抓取的每個小類的鏈接,我們需要自己來定義。爲此,我們在寫了一個索引頁yesky.html,其中列出了所有需要抓取的小類鏈接;

3.定義網站的抓取規則

我們需要抓取天極網的產品名稱、圖片及相關參數:

http://product.yesky.com/digitalcamera/

我們定義了以下規則:

索引頁:yesky_index

產品列表抓取規則:yesky_list

產品詳情頁抓取規則:yesky_detail

4.分層抓取

爲了保證抓取具體產品時,都是有效的線索,我們將抓取工作分爲兩步:第一步,根據索引頁抓取列表線索;第二步,根據列表線索抓取產品詳情;

分層抓取時,我們需要在crontab.xml文件中定義多級抓取規則。(該文件一般位於磁盤:C:/Documents and Settings/(yourLoginName)/.datascraper);

第一步抓取規則如下:

<?xml version="1.0" encoding="UTF-8"?> <crontab> <thread name="project_low"> <parameter> <auto>true</auto> <start>5</start> <period>10800</period> <waitOnload>false</waitOnload> <minIdle>2</minIdle> <maxIdle>10</maxIdle> </parameter> <step name="renewClue"> <theme>yesky_index</theme> </step> <step name="crawl"> <theme>yesky_index</theme> <loadTimeout>3600</loadTimeout> <lazyCycle>3</lazyCycle> <updateClue>true</updateClue> <dupRatio>80</dupRatio> <depth>-1</depth> <width>-1</width> <renew>false</renew> <period>0</period> </step> <step name="crawl"> <theme>yesky_list</theme> <updateClue>true</updateClue> <dupRatio>80</dupRatio> <depth>-1</depth> <width>-1</width> <renew>false</renew> <period>0</period> </step> </thread> </crontab>

第二步抓取規則如下:

<?xml version="1.0" encoding="UTF-8"?> <crontab> <thread name="project_low"> <parameter> <auto>true</auto> <start>5</start> <period>10800</period> <waitOnload>false</waitOnload> <minIdle>2</minIdle> <maxIdle>10</maxIdle> </parameter> <step name="renewClue"> <theme>yesky_list</theme> </step> <step name="crawl"> <theme>yesky_list</theme> <loadTimeout>3600</loadTimeout> <lazyCycle>3</lazyCycle> <updateClue>true</updateClue> <dupRatio>80</dupRatio> <depth>-1</depth> <width>-1</width> <renew>false</renew> <period>0</period> </step> <step name="crawl"> <theme>yesky_detail</theme> <updateClue>true</updateClue> <dupRatio>80</dupRatio> <depth>-1</depth> <width>-1</width> <renew>false</renew> <period>0</period> </step> </thread> </crontab>

Over.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章