本文共 1436 字,大约阅读时间需要 4 分钟。
- 我载nutch1.2并解压:
- # wget http://apache.etoak.com//nutch/apache-nutch-1.2-bin.tar.gz . # tar zxvf apache-nutch-1.2-bin.tar.gz
- 下载tomcat6并解压:
- # wget http://apache.etoak.com/tomcat/tomcat-6/v6.0.32/bin/apache-tomcat-6.0.32.tar.gz # tar zxvf apache-tomcat-6.0.32.tar.gz
- 设置JAVA环境变量
- 在~/.bashrc结尾处添加:export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre,重启终端后生效。
- 配置nutch
- 创建初始url文件,并写入一个(或多个)url # cd nutch-1.2 # mkdir urls.test # echo http://www.sina.com/ > urls.test/iniurls 修改文件conf/crawl-urlfilter.txt:将MY.DOMAIN.NAME替换为sina.com,或者干脆去掉,只留+^http:// 修改文件conf/nutch-default.xml:将http.agent.name的value写为my nutch agent(或其他任意值)
- 开始抓取网络数据
- # ./bin/nutch crawl urls.test/iniurls -depth 3 >& crawl.log 运行完毕后生成文件夹crawl-20110513015802(文件名标识开始爬虫开始时间),若想指定文件夹名字,可在上述命令中加参数 -dir dirname
- 配置搜索引擎
- 进入apache-tomcat-6.0.32/webapps/ROOT #cd ../apache-tomcat-6.0.32/webapps/ROOT/ 删除所有文件 # rm -rf * 解压nutch-1.2/nutch-1.2.war到上述目录 # jar xvf nutch-1.2.war 修改apache-tomcat-6.0.32/webapps/ROOT/WEB-INF/classes/nutch-site.xml,导入已爬取的网络数据的数据库
- 测试搜索引擎
- 开启tomcat6 # cd apache-tomcat-6.0.32 # ./bin/startup.sh 若以上顺利,在浏览器中输入http://localhost:8080,会见到nutch的搜索界面
- 未完待续(修正中文乱码问题)
转载地址:http://hkavi.baihongyu.com/