win7下在cygwin下安装nutch1.2

  • 将nutch解压缩(.gz后缀,可以直接用winRar解压)后将文件夹nutch-1.2(包含文件夹下所有文件)放置到c:/cygwin/home下(我放在c:/cygwin/home下);
  • 打开cygwin,在cygwin环境下进入nutch-1.2目录下(cd /cygdrive/c/cygwin/home/nutch-1.2),使用命令 bin/nutch进行测试,正常的情况下出现的结果是:

      nutch成功后显示

 

  • 抓取网站测试,在C:/cygwin/home/nutch-1.2/下新建一个目录urls,在urls下建一个url.txt文件用以保存需要搜索的网站,在文件中输入http://www.163.com,在C:/cygwin/home/nutch-1.2/下新建一个目录logs,在logs目录下新建log1.log文件用以保存日志文件,在C:/cygwin/home/nutch-1.2/目录下新建一个crawled目录
  • 打开C:/cygwin/home/nutch-1.2/conf/nutch-site.xml,按以下示例输入

<?xml version="1.0"?> 
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> 
<!-- Put site-specific property overrides in this file. --> 
 <configuration> 
 <property> 
  <name>http.agent.name</name> 
  <value>mynutch</value> 
  <description>test 
  </description> 
</property> 
 <property> 
  <name>http.agent.description</name> 
  <value>spider</value> 
  <description> spider 
  </description> 
</property> 
 <property> 
  <name>http.agent.url</name> 
  <value>http://www.xxx.com </value> 
  <description>http://www.xxx.com 
  </description> 
</property> 
 <property> 
  <name>http.agent.email</name> 
  <value>MyEmail</value> 
  <description>md.peter@163.com 
  </description> 
</property> 
 </configuration>

  • C:/cygwin/home/nutch-1.2/conf/crawl-urlfilter.txt文件,把MY.DOMAIN.NAME字符替换为myurl内的域名(比如我改成了“+^http://([a-z0-9]*/.)*163.com/”,其实更简单点,直接删除MY.DOMAIN.NAME这几个字就可以了,也就是说,只保存+^http://([a-z0-9]*/.)*这几个字就可以了,表示所有http的网站都同意爬行)。
  • 运行爬虫,在Cygwin输入以下命令:

          bin/nutch crawl ../urls/url.txt -dir ../crawled -depth 4 -threads 5 -topN 1000 >&logs/log1.log

         这里-dir表示存储的目录,-depth表示网址爬的深度,最后是指明日志文件

         运行结束后,你可以打开日志文件查看爬虫运行的详细过程。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值