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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述