Nutch导入eclipse
最近在开始研究nutch刚把它在eclipse中跑起来,方便研究源码吧。本文针对的是nutch1.1版本。如有不对的地方欢迎指证。
直接导入eclipse.
1.首先下载nutch的最新版本, http://apache.etoak.com/nutch/ 本文写作时nutch的最新版本为1.1。所以本文以下所述均针对nutch1.1。(注意笔者在下载时发现该版本的src包有问题。换成bin包后正常)
2.在eclipse中新建立一个Java Project. 名字自己定义(Nutch). 选择"Create project from existing source",指向自己nutch-1.0的目录.
3.单点finish完成。这时就把nutch的整个工程全部导入到了 eclipse中了。
4.此时还需将conf文件下的所有配置文件加入到classPath中。
右键conf――>Build PathàUse as Source Folder
5.修改配置文件
conf/nutch-site.xml <configuration>中加入以下内容。
<property>
<name>http.agent.name</name>
<value>test</value>
<description>
HTTP 'User-Agent' request header. MUST NOT be empty - please
set this to a single word uniquely related to your
organization. NOTE: You should also check other related
properties: http.robots.agents http.agent.description
http.agent.url http.agent.email http.agent.version and set
their values appropriately.
</description>
</property>
<property>
<name>http.agent.description</name>
<value>test</value>
<description>
Further description of our bot- this text is used in
the User-Agent header. It appears in parenthesis after the
agent name.
</description>
</property>
<property>
<name>http.agent.url</name>
<value>www.163.com</value>
<description>
A URL to advertise in the User-Agent header. This will
appear in parenthesis after the agent name. Custom dictates
that this
should be a URL of a page explaining the purpose and
behavior of this
crawler.
</description>
</property>
<property>
<name>http.agent.email</name>
<value>xxx@126.com</value>
<description>
An email address to advertise in the HTTP 'From' request
header and User-Agent header. A good practice is to mangle this
address (e.g. 'info at example dot com') to avoid spamming.
</description>
</property>
conf/nutch-default.xml
<property>
<name>plugin.folders</name>
<value>./src/plugin</value><!—修改部分-->
conf/crawl-urlfilter.txt
#accept hosts in MY.DOMAIN.NAME
+^http://([a-z0-9]*\.)*163.com/ ---写入想抓取的网站正则表达式
6.在工程的根目录下建立urls文件夹,其中新建一个url.txt文件,该文件中写入想抓取的网站URL,如:http://www.163.com/
7.执行nutch的 crawl命令。
至此nutch导入eclipse中运行成功。
手动复制导入nutch代码到eclipse中.(目录结构更清楚)
通过以上方式虽然可以成功的将nutch导入eclipse中,但工程目录结构极为不适合,所以笔者又以手动的方式将nutch的源代码导入eclipse中,使目录更清晰。具体步骤如下:
1.在eclipse中新建立一个Java Project. 名字自己定义(Nutch). 选择"Create New project in WorkSpace".点击完成。
2.将解压后的nutch目录下的\src\java\中的代码全部复制到新建工程中的src下。
将解压后的nutch目录下的lib、plugins、conf三个文件夹复制到新建工程的根目录下(与src同级)
3.右键工程properties, 切换到"Libraries"选择"Add Class Folder..." 按钮,从列表中选择"conf". 将 conf加入到classpath中。
4.修改配置文件
(1)conf/nutch-site.xml 同上.
(2)conf/nutch-default.xml
<property>
<name>plugin.folders</name>
<value> ./plugins</value><!—小心这里路径变了,笔者曾在此费了大半天时间-->
(3) conf/crawl-urlfilter.txt 同上。
(4)新建urls。同上
布署nutch搜索到tomcat.
1.安装WAR文件
将WAR文件$nutch$/nutch-*.war拷贝到目录$tomcat$/webapps/.这样就可以通过URL: http://127.0.0.1:8080/nutch 来打开搜索主页面。
注意:如果你的tomcat中的默认JDK不是1.6。启动tomcat时就会报“错误的版本”的异常。这时就需要修改tomcat的JDK版本。
配置tomcat使用特定的java sdk版本的方法非常简单:
1、修改tomcat/bin/catalina.bat,增加 set JAVA_HOME=XXXXXX,其中XXXXXX为jdk 的路径,如c:\j2sdk1_6
2、修改tomcat/bin/setclasspath.bat,同样增加 set JAVA_HOME=XXXXXX
其实这个问题是很初级的,但是一般人常常忘了步骤2,导致的结果就是特定版本的java启动tomcat,但是jdk用的还是系统默认的(在系统的JAVA_HOME中的设置)。
2. 指定搜索数据目录
需要为搜索服务程序指定数据文件的位置。
假设WAR文件保存为nutch.war,重启动Tomcat,解压缩成目录$tomcat$/webapps/nutch/。
打开文件$tomcat$/webapps/nutch/WEB-INF/classes/nutch-site.xml,添加searcher.dir属性,例如数据文件保存在/local/nutch/crawl目录中,则添加:
<property>
<name>searcher.dir</name>
<value>/local/nutch/crawl</value>
</property>
这样search.jsp就知道数据文件的在哪里了.
分享到:
相关推荐
eclipse配置nutch,eclipse配置nutch
Eclipse 编译 Nutch-0.9
apache-nutch-2.2.1(Eclipse直接运行版)今天刚做的,发现有很多坑,分享给大家实验,JDK1.7 Win10。我分享的两个压缩卷一起下载才可以用,资源限制太小了 002地址:...
Eclipse 中编译 Nutch-1.0 运行源代码
1.1 环境准备 1.1.1 本期引言 1.1.2 环境介绍 1.1.3 JDK 安装配置 1.1.4 ANT 安装配置 1.1.5 IvyDE 安装配置 1.1.5 Tomcat 安装配置 1.1.6 Cygwin 安装配置 ...1.2.2 Nutch 导入 1.2.3 Solr 与Nutch 结合
已编译好的版本,可以直接导入eclipse、idea。Nutch 是一个开源Java 实现的搜索引擎。它提供了我们运行自己的搜索引擎所需的全部工具。包括全文搜索和Web爬虫。
Windows下使用Eclipse配置Nutch2图文详解
nutch2.1导入Eclipse过程中,import org.restlet.×;错误,缺少的包。
nutch2.1导入Eclipse过程中,import org.restlet.×;错误,缺少的包。
将nutch1.2源码嵌入到myeclipse8.5 在window环境的nutch1.2的简单应用 将其放于tomcat的webapp下
Nutch教程——导入Nutch工程,执行完整爬取 Nutch流程控制源码详解(bin/crawl中文注释版) Nutch教程——URLNormalizer源码详解 Nutch参数配置——http.content.limit ...
本文章修改了在eclipse中加入Nutch的详细过程!
Eclipse中编译Nutch-1.0。。。。。。。。。。。。
nutch 在windows下环境搭配 已经如何在eclipse下配置,有配图,很详细
1.1什么是nutch..1 1.2研究nutch的原因...1 1.3 nutch的目标..1 1.4 nutch VS lucene.....2 2. nutch的安装与配置.....3 2.1 JDK的安装与配置.3 2.2 nutch的安装与配置........5 2.3 tomcat的安装与配置......5 3. ...
提高nutch运行效率的原理与方法,nutch的运行过程相对来说还是很慢的,对于一些特殊的应用来说,必须对nutch做很多修改来达到提高速度的目的,本人在这方面有深入研究,可以提高2-5倍性能。
1.1 Nutch 基本原理 1.1.1 Nutch 基本组成 1.1.2 Nutch 工作流程 1.2 Nutch 流程详解 1.2.1 Nutch 数据流程 1.2.2 Nutch 流程分析
nutch应用,nutch中文分词,nutch中文乱码
Nutch搜索引擎·Nutch简单应用(第3期) 1.1 Nutch 命令详解 1.2 Nutch 简单应用
nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据