DataScraper資料抓取快速入門

來源:互聯網
上載者:User

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

可參考以下幾篇文章:

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

案例:如何規劃網站資料擷取:

http://www.goo seeker.com/cn/node/Fulelr/2009120501

卓越網商品資料分級抓取:

http://www.goo seeker.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.

More:http://blog.donews.com/me1105/archive/2011/04/09/143.aspx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.