`
xxj
  • 浏览: 420145 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Nutch 笔记(一):Quick Start

阅读更多
最近用到了nutch,目的是针对指定的一些网站抓取其内容,然后做分析用。
nutch 笔记是我使用nutch过程一系列总结,写下自己的学习经过和大家一起分享,也希望能得到大家的指点

好了,废话少说,言归正传,第一篇:Quick Start,我们的目标是快速的能跑起来,能检索出我们想要的结果。

首先要明白nutch是什么?
nutch是一个基于lucene的开源搜索引擎,它包括了所有你想要的东西,是一个完整的解决方案 。


一:安装JDK
如果你已经安装了JDK,并且已经设置了JAVA_HOME,那么跳过这一步
安装jdk
sudo apt-get install sun-java5-jdk

或者从sun公司网站下载bin文件执行安装

设置了JAVA_HOME
sudo vi ~/.bashrc

在最后面增加
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
export PATH=$PATH:$JAVA_HOME/bin


二:下载nutch的最新版本nutch0.8.1
wget http://apache.justdn.org/lucene/nutch/nutch-0.8.1.tar.gz


释放下来即可
tar zxvf nutch-0.8.1.tar.gz


三:抓取页面
增加url
cd nutch-0.8.1
mkdir urls
echo http://www.xici.net>>urls/xici


编辑conf/crawl-urlfilter.txt,修改MY.DOMAIN.NAME为
+^http://([a-z0-9]*.)*xici.net/


修改conf/nutch-site.xml,增加http.agent.name值
  <property>
     <name>http.agent.name</name>
     <value>test/unique</value>
  </property>


执行bin/nutch crawl开始抓取页面
sudo bin/nutch crawl urls -dir crawl -depth 5 -topN 50&


这个过程需要等待一些时间

三:检索
安装tomcat,我们使用apache网站上的包
cd ..
wget http://mirror.vmmatrix.net/apache/tomcat/tomcat-5/v5.5.20/bin/apache-tomcat-5.5.20.tar.gz
tar zxvf apache-tomcat-5.5.20.tar.gz


将nutch自带的war文件拷贝到webapps下面
rm -rf apache-tomcat-5.5.20/webapps/ROOT*
cp nutch-0.8.1/nutch*.war apache-tomcat-5.5.20/webapps/ROOT.war


运行tomcat,如果不设定nutch-site.xml的searcher.dir的值,则需要在crawl目录下面执行
sudo ${TOMCAT的目录}/bin/startup.sh


我们也可以设定nutch-site.xml的searcher.dir的值
sudo vi ${TOMCAT的目录}/webapps/ROOT/WEB-INF/classes/nutch-site.xml


增加
  <property>
    <name>searcher.dir</name>
    <value>/home/martin/doc/nutch-0.8.1/crawl</value>
  </property>



四:中文乱码
修改tomcat的server.xml,在Connector的tag最后增加
URIEncoding="UTF-8"


五:截图


-----------------------
nutch site:http://lucene.apache.org/nutch
nutch wiki:http://wiki.apache.org/nutch/


下一篇笔记:Nutch 笔记(二):Craw more urls and Recrawl:http://martin.iteye.com/blog/27193
分享到:
评论
5 楼 w156445045 2013-03-15  
博主我用的是1.6的版本,我没找到conf/crawl-urlfilter.txt这个文件呢
还有那个war文件,楼主找到了没有啊?谢谢。
4 楼 wuwu_papaya 2007-01-07  
请问一下哦,我也装了0.8.1,不过我页面一打开怎么有javascript错误呢,你得有吗
3 楼 xxj 2006-10-15  
在windows下,你安装个cygwin。
2 楼 xxj 2006-10-13  
  thanks
1 楼 xxj 2006-10-13  
some useful resources:

http://today.java.net/pub/a/today/2006/01/10/introduction-to-nutch-1.html
http://today.java.net/pub/a/today/2006/02/16/introduction-to-nutch-2.html

http://www.dbanotes.net/archives/2005/01/nutch_aee.html
http://www.dbanotes.net/web/nutch_1.html

http://hedong.3322.org/archives/000247.html

相关推荐

Global site tag (gtag.js) - Google Analytics