标签存档: nutch

Nutch 1.2 在Eclipse中的配置 (2)

Nutch + Resin 在Eclipse的配置

经过Nutch 1.2 在Eclipse中的配置 (1),之后就需要看看搜索效果了

1. 需安装Eclipse中的resin插件,更新地址:http://caucho.com/eclipse/

2. 配置resin.conf到Nutch的根目录,修改相应的<http>和<host>标签为如下:

<!-- The http port -->
<http server-id="" host="*" port="3331"/>

...

<host id="" root-directory=".">
    <resin:set var="resin_admin_password"  default=""/>
    <resin:set var="resin_admin_localhost" default="true"/>
    <web-app id="/nutch" document-directory="E:\Projects\Nutch\apache-nutch-1.2\web"/>
</host>

这里使用的为resin3

3.启动resin,可以通过 http://localhost:3331/nutch访问

Nutch 1.2 在Eclipse中的配置 (1)

Nutch Crawl 在Eclipse的配置

下载Nutch : http://www.apache.org/dyn/closer.cgi/nutch/ 当前最新版本为1.2

通过新建Java Project 将Nutch导入进Eclipse中

将conf文件夹引用为source folder

在nutch项目的根目录建立urls文件夹, 并新建文件url.txt, 内容如下:

http://www.yahoo.com.cn/

http://www.163.com/

修改conf/crawl-urlfilter.txt内容:

# accept hosts in MY.DOMAIN.NAME

+^http://([a-z0-9]*\.)*MY.DOMAIN.NAME/

修改为

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

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

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

修改conf/nutch-site.xml文件内容:

<configuration>

<property>

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

<value>*</value>

</property>

</configuration>

修改conf/nutch-defaul.xml文件, 将属性”plugin.folders”的值由“plugins”更改为 “./src/plugin”

Eclipse中选择Run as… , 配置一个新的Java Application

Main选项卡中的Main class选择org.apache.nutch.crawl.Crawl

Arguments选项卡中:

Program arguments 填入urls -dir crawl -depth 3 -topN 50,

VM arguments填入 -Dhadoop.log.dir=logs -Dhadoop.log.file=hadoop.log -Xms64m -Xmx512m

最后点击Run就可以开始Crawl了

也可以将Paoding中文分词插件加入Nutch中