Nutch 初体验作者:Fenng 出处:http://www. 日期:January 02, 2005 « ITPub Search Plugin for Firefox and Mozilla | Blog首页 | Google PR 更新以及其他 » 前几天看到卢亮的 Larbin 一种高效的搜索引擎爬虫工具 一文提到 Nutch,很是感兴趣,但一直没有时间进行测试研究。趁着假期,先测试一下看看。用搜索引擎查找了一下,发现中文技术社区对 Larbin 的关注要远远大于 Nutch 。只有一年多前何东在他的竹笋炒肉中对 Nutch 进行了一下介绍。 Nutch vs Lucene Nutch vs GRUB Nutch vs Larbin Nutch 的早期版本不支持中文搜索,而最新的版本(2004-Aug-04 发布了 0.5)已经做了很大的改进。相对先前的 0.4 版本,有 20 多项的改进,结构上也更具备扩展性。0.5 版经过测试,对中文搜索支持的也很好。 下面是我的测试过程。 前提条件(这里Linux 为例,如果是 Windows 参见手册):
首先下载最新的稳定版: [root@fc3 ~]# wget http://www./release/nutch-0.5.tar.gz 解压缩: [root@fc3 ~]# tar -zxvf nutch-0.5.tar.gz ...... [root@fc3 ~]# mv nutch-0.5 nutch 测试一下 nutch 命令: [root@fc3 nutch]# bin/nutch Usage: nutch COMMAND where COMMAND is one of: crawl one-step crawler for intranets admin database administration, including creation inject inject new urls into the database generate generate new segments to fetch fetchlist print the fetchlist of a segment fetch fetch a segment‘s pages dump dump a segment‘s pages index run the indexer on a segment‘s fetcher output merge merge several segment indexes dedup remove duplicates from a set of segment indexes updatedb update database from a segment‘s fetcher output mergesegs merge multiple segments into a single segment readdb examine arbitrary fields of the database analyze adjust database link-analysis scoring server run a search server or CLASSNAME run the class named CLASSNAME Most commands print help when invoked w/o parameters. [root@fc3 nutch]# Nutch 的爬虫有两种方式
以本站(http://www.)为例,先进行一下针对企业内部网的测试。 在 nutch 目录中创建一个包含该网站顶级网址的文件 urls ,包含如下内容:http://www./ 然后编辑conf/crawl-urlfilter.txt 文件,设定过滤信息,我这里只修改了MY.DOMAIN.NAME: # accept hosts in MY.DOMAIN.NAME +^http://([a-z0-9]*\.)*/ 运行如下命令开始抓取分析网站内容: [root@fc3 nutch]# bin/nutch crawl urls -dir crawl.demo -depth 2 -threads 4 >& crawl.log depth 参数指爬行的深度,这里处于测试的目的,选择深度为 2 ; 在该命令运行的过程中,可以从 crawl.log 中查看 nutch 的行为以及过程: ...... 050102 200336 loading file:/u01/nutch/conf/nutch-site.xml 050102 200336 crawl started in: crawl.demo 050102 200336 rootUrlFile = urls 050102 200336 threads = 4 050102 200336 depth = 2 050102 200336 Created webdb at crawl.demo/db ...... 050102 200336 loading file:/u01/nutch/conf/nutch-site.xml 050102 200336 crawl started in: crawl.demo 050102 200336 rootUrlFile = urls 050102 200336 threads = 4 050102 200336 depth = 2 050102 200336 Created webdb at crawl.demo/db 050102 200336 Starting URL processing 050102 200336 Using URL filter: net.nutch.net.RegexURLFilter ...... 050102 200337 Plugins: looking in: /u01/nutch/plugins 050102 200337 parsing: /u01/nutch/plugins/parse-html/plugin.xml 050102 200337 parsing: /u01/nutch/plugins/parse-pdf/plugin.xml 050102 200337 parsing: /u01/nutch/plugins/parse-ext/plugin.xml 050102 200337 parsing: /u01/nutch/plugins/parse-msword/plugin.xml 050102 200337 parsing: /u01/nutch/plugins/query-site/plugin.xml 050102 200337 parsing: /u01/nutch/plugins/protocol-http/plugin.xml 050102 200337 parsing: /u01/nutch/plugins/creativecommons/plugin.xml 050102 200337 parsing: /u01/nutch/plugins/language-identifier/plugin.xml 050102 200337 parsing: /u01/nutch/plugins/query-basic/plugin.xml 050102 200337 logging at INFO 050102 200337 fetching http://www./ 050102 200337 http.proxy.host = null 050102 200337 http.proxy.port = 8080 050102 200337 http.timeout = 10000 050102 200337 http.content.limit = 65536 050102 200337 http.agent = NutchCVS/0.05 (Nutch; http://www./docs/en/bot.html; n utch-agent@lists.) 050102 200337 fetcher.server.delay = 1000 050102 200337 http.max.delays = 100 050102 200338 http://www./: setting encoding to GB18030 050102 200338 CC: found http:///licenses/by-nc-sa/2.0/ in rdf of http: //www./ 050102 200338 CC: found text in http://www./ 050102 200338 status: 1 pages, 0 errors, 12445 bytes, 1067 ms 050102 200338 status: 0.9372071 pages/s, 91.12142 kb/s, 12445.0 bytes/page 050102 200339 Updating crawl.demo/db 050102 200339 Updating for crawl.demo/segments/20050102200336 050102 200339 Finishing update 64,1 7% 050102 200337 parsing: /u01/nutch/plugins/query-basic/plugin.xml 050102 200337 logging at INFO 050102 200337 fetching http://www./ 050102 200337 http.proxy.host = null 050102 200337 http.proxy.port = 8080 050102 200337 http.timeout = 10000 050102 200337 http.content.limit = 65536 050102 200337 http.agent = NutchCVS/0.05 (Nutch; http://www./docs/en/bot.html; nutch-agent@lists.) 050102 200337 fetcher.server.delay = 1000 050102 200337 http.max.delays = 100 ...... 之后配置 Tomcat (我的 tomcat 安装在 /opt/Tomcat) , [root@fc3 nutch]# rm -rf /opt/Tomcat/webapps/ROOT* [root@fc3 nutch]# cp nutch*.war /opt/Tomcat/webapps/ROOT.war [root@fc3 webapps]# cd /opt/Tomcat/webapps/ [root@fc3 webapps]# jar xvf ROOT.war [root@fc3 webapps]# ../bin/catalina.sh start 浏览器中输入 http://localhost:8080 查看结果(远程查看需要将 localhost 换成相应的IP): ![]() 搜索测试: ![]() 可以看到,Nutch 亦提供快照功能。下面进行中文搜索测试: ![]() 注意结果中的那个“评分详解”,是个很有意思的功能(Nutch 具有一个链接分析模块),通过这些数据可以进一步理解该算法。 考虑到带宽的限制,暂时不对整个Web爬行的方式进行了测试了。值得一提的是,在测试的过程中,nutch 的爬行速度还是不错的(相对我的糟糕带宽)。 Nutch 目前还不支持 PDF(开发中,不够完善) 与 图片 等对象的搜索。中文分词技术还不够好,通过“评分详解”可看出,对中文,比如“数据库管理员”,是分成单独的字进行处理的。但作为一个开源搜索引擎软件,功能是可圈可点的。毕竟,主要开发者 Doug Cutting 就是开发 Lucene 的大牛 参考信息
|
|