Nutch1.4安装及测试

来源:互联网 发布:货运app软件 编辑:程序博客网 时间:2024/06/11 22:14

Nutch安装及测试

 

一 安装环境:

Ubuntu 版本:11.10

Kernel  版本:3.0.0.12-generic

 

二 安装Java的JDK

安装JDK命令:apt-getinstall openjdk-6-jdk

 

三 下载Nutch及解压安装

       Nutch版本:apache-nutch-1.4-bin.tar.gz

       命令下见图:

 

 

四 设置环境变量:

      

问题一:当设置完环境变量后,在命令行输入”nutch”,然后回车,无法运行nutch,且出现现提示:“/home/is11/lidexin/apache-nutch-1.4-bin/runtime/local/bin/nutch:Permission denied”

解决方法:在目录“/home/is11/lidexin/apache-nutch-1.4-bin/runtime/local/bin/”下输入命令“chmod +x nutch”,然后回车。(见下图)

(注意此问题不一定会出现,我在ubuntu10.04上安装Nutch时就没出现过)

 

五 建立urls目录

       在目录“/apache-nutch-1.4-bin/runtime/local”下建立urls目录,见下图

 

六 在urls目录下建立url.txt文件,并输入你想爬的网站网址。

 

七 编辑nutch-site.xml文件。

       进入到/apache-nutch-1.4-bin/runtime/local/conf目录下,修改nutch-site.xml文件。命令见下图。

 

添加内容如下:


八 编辑regex-urlfilter.txt文件

进入到/apache-nutch-1.4-bin/runtime/local/conf目录下,修改regex-urlfilter.txtl文件,在“# accept anything else”下面输入:“+^http://([a-z0-9*\.])*mittrchinese.com/”,然后保存,见下图

 

  

 

九 开始爬了

   命令:nutch crawl urls –dir crawl –depth 3 –topN 5

   此命令的意思:“We are using the nutch crawlcommand. The urlsdir is the urls directory that we added to the distributedfilesystem. (I've called it "urlsdir" to make it clearer that itisn't merely the *file* containing urls). The "-dir crawl" is theoutput directory. This will also go to the distributed filesystem. The depth is3 meaning it will only get 3 page links deep. There are other options you canspecify, see the command documentation for those options.”

引之网站:http://wiki.apache.org/nutch/NutchHadoopTutorial

 

问题二:出现错误提示,见下图

 

 

解决方法如下:

       回到/apache-nutch-1.4-bin/runtime/local目录下,执行“chmod +x urls”命令,回车。

       (注意此问题不一定会出现,我在ubuntu10.04上安装Nutch时就没出现过)


 

重新输入命令:nutch crawl urls –dir crawl –depth 3 –topN 5

屏幕显示如下:

 

 


借鉴的主要网站:http://nutch.apache.org/

http://www.open-open.com/lib/view/open1328670771405.html

http://www.cnblogs.com/wycg1984/archive/2010/06/25/1764926.html

http://luckaway.iteye.com/blog/568496

http://www.cppblog.com/AutomateProgram/archive/2011/05/04/145657.html

http://blog.csdn.net/Mylady58/article/details/5891190

http://wiki.apache.org/nutch/NutchHadoopTutorial

 

 

 

原创粉丝点击