linux下搭建nutch-1.3

我的安装环境Red Hat Enterprise Linux5,jdk6,tomcat6。

1.   环境需求

1.1        Sun JDK 1.5 or 更高版本,设置NUTCH_JAVA_HOME为您的JVM安装的根。

1.2        Apache’s Tomcat 5.x or 更高版本。

1.3        1Gb的硬盘空间

2.   准备开始

首先你需要得到nutch的安装包

http://labs.renren.com/apache-mirror//nutch/

我下载的是apache-nutch-1.3-bin.tar.gz。解压并进入他的根目录

执行如下命令

runtime/local/bin/nutch得到-bash:runtime/local/bin/nutch: 权限不够。说明nutch没有执行权限

chomd 755 runtime/local/bin/nutch  (付给nutch执行权限)

再执行runtime/local/bin/nutch将显示nutch命令的用法。

很好!你可以准备“抓“你的网站了,你需要给你的crawler一个名字,这是必须的。否则他不能“抓”。

编辑$NUTCH_HOME/conf/nutch-site.xml($NUTCH_HOME/runtime/local/conf/nutch-site.xml with version >= 1.3)添加如下内容

<property>

 <name>http.agent.name</name>

 <value>你的CRAWLER的名字</value>

</property>

用任何你想要的名字代替“你的CRAWLER的名字”。

现在我们要准备crawl,有两种方法来crawl。

3.抓取命令

当你打算爬上少数Web服务器上的约100万页,检索命令是比较合适的。

抓取命令:配置

要抓东西,你必须配置的东西

A.创建一个目录,在此目录中创建一个文件,该文件里存放网址。例如,要抓取Nutch的网站,你不妨先创建文件名为urls/nutch的文件,该文件里只是包含Nutch的主页的网址。从这个网页,所有其他的Nutch的页面应该可以访问到。因此该文件应该包含 http://lucene.apache.org/nutch/

B.编辑文件$NUTCH_HOME/runtime/local/conf/regex-urlfilter.txt并且代替

# accept anything else+.  

匹配您要抓取的域。例如,如果你希望限制​​抓取到apache.org域中,该行应改为:

+^http://([a-z0-9]*\.)*apache.org/ 

这个这则表达式将包括所有的apache的网址。

抓取命令:运行抓取

一旦事情配置好,运行抓取是很容易的。只需使用抓取命令。其选项包括:

·        -dir dir names thedirectory to put the crawl in.

·        -threads threads determines thenumber of threads that will fetch in parallel.

·        -depth depth indicatesthe link depth from the root page that should be crawled.

·        -topN N determines the maximum number of pages that will be retrieved ateach level up to the depth.

典型的命令bin/nutch crawl urls/nutch -dir crawl -depth 3 -topN 50 

{Typicallyone starts testing one's configuration by crawling at shallow depths, sharplylimiting the number of pages fetched at each level (-topN), and watching theoutput to check that desired pages are fetched and undesirable pages are not.Once one is confident of the configuration, then an appropriate depth for afull crawl is around 10. The number of pages per level (-topN) for a full crawlcan be from tens of thousands to millions, depending on your resources.}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值