免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2749 | 回复: 0
打印 上一主题 下一主题

Windows下Nutch的配置过程,及导入Eclipse的步骤 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-03-16 15:46 |只看该作者 |正序浏览
转自 http://www.javaeye.com/topic/934862

1.下载并安装cygwin,安装和环境配置不细说了。将%CYGWIN_HOME%\bin加到path中。

2.导入到Eclipse中

①在Eclipse中添加File > New > Project > Java project。
project name随便,选择 “Create project from existing source” ,在browse中选nutch的解压路径,如D:\nutch-1.2

②在“Add Class Folder” 中选择 conf 文件夹。

③然后再定义一个“Default ouput folder” ,名称任意。注意不能选bin文件夹,因为如果选了bin文件夹做为Default output folder 编译时会清空该文件夹,bin下的其他文件会被删掉,导致其他问题。

④Finish.

3.修改Nutch的配置文件,这里以抓取www.163.com为例。

①修改D:\nutch-1.2\conf下的nutch-site.xml配置
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet href="configuration.xsl"?>
  3. <!-- Put site-specific property overrides in this file. -->
  4. <configuration>

  5. <property>
  6.   <name>http.agent.name</name>
  7.   <value>nutch-1.2</value>
  8.   <description>HTTP 'User-Agent'</description>
  9. </property>

  10. <property>
  11.   <name>searcher.dir</name>
  12.   <value>D:\nutch-1.2\crawl</value>
  13.   <description>Path to root of crawl.</description>
  14. </property>

  15. </configuration>
复制代码
②修改在D:\nutch-1.2\conf下的crawl-urlfilter.txt
  1. # accept hosts in MY.DOMAIN.NAME
  2. +^http://([a-z0-9]*\.)*163.info/
  3. # skip everything else
复制代码
③修改D:\nutch-1.2\conf下的nutch-default.xml
  1. <property>
  2.   <name>plugin.folders</name>
  3.   <value>./src/plugin</value>
  4.   <description>Directories where nutch plugins are located.  Each
  5.   element may be a relative or absolute path.  If absolute, it is used
  6.   as is.  If relative, it is searched for on the classpath.</description>
  7. </property>
复制代码
④在D:\nutch-1.2\下,建立名为urls的文件夹,并在文件夹内建立url.txt的文本,写入
  1. http://www.163.com/
复制代码
4. 在Eclipse里运行Nutch

①Run-open run dialog

②name随便写

③在main class填写
  1. org.apache.nutch.crawl.Crawl
复制代码
④arguments填写
  1. urls -dir crawl -depth 3 -topN 50
复制代码
⑤在VM arguments填写
  1. -Dhadoop.log.dir=logs -Dhadoop.log.file=hadoop.log
复制代码
OK,运行,看Nutch在爬啊爬啊。
  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP