nutch 为何物,在这儿我就不做介绍了,因为google比我管用哈。
今天我来介绍一下,nutch1.2更新版本的eclipse导入进入编译开发,为二次开发nutch做准备。
主要有以下几步:
(一)安装cygwin,此步骤也很重要,不安装的话,会报环境错误。具体的安装过程google一下就ok了。
(二)下载nutch1.2到指定一个目录下,并打开eclipse新建一个java工程。并选择"Create project
from existing source",指向nutch目录。
(三) 下一步操作,切换到"Libraries"选择"Add Class Folder..." 按钮,从列表中选择"conf"。
(四)继续操作:切换到"Order and Export"找到"conf",把它移到顶端。不用选择它。
(五)到"Source"将output folder设置为Nutch /bin/tmp_build,点击finish完成导入。
(六) 配置,配置文件:nutch-default.xml,nutch-site.xml,crawl-urlfilter.txt。
1) nutch-default.xml
修改此处:
<property>
<name>plugin.folders</name>
<value>./src/plugin</value>
<description>Directories where nutch plugins are located. Each
element may be a relative or absolute path. If absolute, it is used
as is. If relative, it is searched for on the classpath.</description>
</property>
2) 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>wenda.tianya.cn</value>
<description>HTTP ‘User-Agent’ request header. </description>
</property>
<property>
<name>http.agent.description</name>
<value>wenda.tianya.cn</value>
<description>Further description of our bot- this text is used in the
User-Agent header.
</description>
</property>
<property>
<name>http.agent.url</name>
<value>http://wenda.tianya.cn/wenda/</value>
<description>A URL to advertise in the User-Agent header.
</description>
</property>
<property>
<name>http.agent.email</name>
<value>lsoba@gmail.com</value>
<description>An email address to advertise in the HTTP ‘From’ reques
header and User-Agent header.
</description>
</property>
</configuration>
3)crawl-urlfilter.txt
具体自己的情况而定 (可以google一下用法,网上有很清晰的说明)
(七) 创建urls目录 以及copy nutch-1.2.jar与nutch-1.2.job 到工作目录的要目录
(八) 运行crawl 可执行类
配置运行环境:
Program arguments:
urls -dir f:/index -depth 3 -topN 300
VM arguments:
-Dhadoop.log.dir=logs -Dhadoop.log.file=hadoop.log
欢迎大家拍砖!