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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值