DataScraper数据抓取快速入门

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

原文地址:https://www.cnblogs.com/me115/p/2010978.html