Nutch0.9安装手册(windows)

一、安装JDK

    1、下载地址:http://java.sun.com/javase/downloads/index.jsp

    2、 安装目录:安装目录自己选择,这里假设为:d:/Program Files/Java/jdk/

    3、设置Path环境变量:右键我的电脑--属性--高级--环境变量--系统变量 编辑Path变量增加目录d:/Program Files/Java/jdk/bin

    4、设置JAVA_HOME环境变量变量:同上,新建一个JAVA_HOME环境变量,值为d:/Program Files/Java/jdk/

    5、在cmd中输入java -version 如果同你安装的jdk版本,说明安装成功

二、安装Tomcat

    1、下载地址:http://tomcat.apache.org/

    2、安装目录:安装目录自己选择,这里假设为:d:/Program Files/tomcat

    3、设置TOMCAT_HOME环境变量:方法同上,新建一个TOMCAT_HOME环境变量,值为d:/Program Files/tomcat

    4、编辑tomcat/conf下面的server.xml 文件,找到Connector port="8080" 给这节点增加2个属性URIEncoding="UTF-8" useBodyEncodingForURI="true",修改这里的目的是修改tomcat编码为UTF-8,nutch使用的是该编码否则中文会出现乱码

    5、启动tomcat:d:/Program Files/tomcat/bin 下找到startup.bat 双击启动

    6、在浏览器中输入:http://127.0.0.1:8080/  出现欢迎界面表示安装成功

三、安装Cygwin

    提示:至少要2G空间

    1、下载地址:http://www.cygwin.com/setup.exe

    2、安装目录:安装目录自己选择,这里假设为:d:/Program Files/cygwin  选择最基本的安装

四、安装Nutch

    1、下载地址:http://apache.mirror.phpchina.com/lucene/nutch/nutch-0.9.tar.gz

    2、解压到目录:d:/Program Files/nutch 

    3、在d:/Program Files/nutch 目录下建立一个urls.txt文件,编辑该文件,写上你要爬的网站,比如http://www.wokenet.com/bbs

    4、打开nutch/conf/crawl-urlfilter.txt文件,把MY.DOMAIN.NAME字符替换为url.txt内的url的域名,其实更简单点,直接删除MY.DOMAIN.NAME这几个字就可以了,也就是说,只保存+^http://([a-z0-9]*/.)*这几个字就可以了,表示所有http的网站都同意爬行。

    5、打开nutch/conf/conf/nutch-site.xml文件,在<configuration></configuration>内插入以下内容:

    

  1. <property> 
  2.     <name>http.agent.name</name> 
  3.     <value>nutchcvs</value> 
  4.     <description>HTTP 'User-Agent' request header. MUST NOT be empty - 
  5.         please set this to a single word uniquely related to your organization.  
  6.         NOTE: You should also check other related properties: 
  7.         http.robots.agents 
  8.         http.agent.description 
  9.         http.agent.url 
  10.         http.agent.email 
  11.         http.agent.version 
  12.         and set their values appropriately. 
  13.     </description> 
  14. </property> 
  15. <property> 
  16.  <name>http.agent.description</name> 
  17.  <value></value> 
  18.  <description>Further description of our bot- this text is used in 
  19.     the User-Agent header. It appears in parenthesis after the agent name. 
  20.     </description> 
  21. </property> 
  22. <property> 
  23.     <name>http.agent.url</name> 
  24.     <value></value> 
  25.     <description>A URL to advertise in the User-Agent header. This will 
  26.         appear in parenthesis after the agent name. Custom dictates that this 
  27.         should be a URL of a page explaining the purpose and behavior of this 
  28.         crawler. 
  29.     </description> 
  30. </property> 
  31. <property> 
  32.  <name>http.agent.email</name> 
  33.  <value></value> 
  34.  <description>An email address to advertise in the HTTP 'From' request 
  35.         header and User-Agent header. A good practice is to mangle this 
  36.         address (e.g. 'info at example dot com') to avoid spamming. 
  37.     </description> 
  38. </property> 

  五、用nutch进行爬行

    由于配置nutch采用的是单独网站的配置方式,所以执行上我们也采用的是单网查询,全网查询在以后的内容中介绍。

    先看一看nutch给出的命令:nutch crawl urls.txt -dir crawl -depth 3 -topN 50

    crawl:通知nutch.jar,执行crawl的main方法。
    urls:存放需要爬行的url.txt文件的目录,注意,这个名字需要和你的文件夹目录相同,如果你的文件夹为search,那这里也应该改成search。
    -dir crawl:爬行后文件保存的位置,可以在nutch/bin目录下找到。
    -depth 3:爬行次数,或者成为深度,不过还是觉得次数更贴切,建议测试时改为1。
    -topN 50:一个网站保存的最大页面数。

    1、打开cygwin的快捷方式,用cd命令进入nutch安装目录d:/Program Files/nutch  执行命令:sh ./bin/nutch crawl urls.txt -dir crawl -depth 3 -topN 50

    2、等待爬行结束后 

六、执行查询

    1、在nutch安装目录下找到nutch-0.9.war文件,改名为nutch.war解压到tomcat/webapps目录下。

    2、webapps/nutch/WEB-INF/classes/nutch-site.xml 文件内容如下:

    

  1. <property>
  2.     <name>searcher.dir</name> 
  3.     <value>d:/Program Files/nutch/crawl</value> 
  4. </property>

 

    3、启动tomcat,在浏览器中输入http://127.0.0.1:8080/nutch 好了,恭喜你安装成功了!

 

大家可以看看我使用nutch开发的例子:笔记本搜索引擎蜗壳网http://www.wokenet.com/

如果还有什么疑问可以给我留言,谢谢查看

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值