Friday, October 23rd, 2009
nutch网上有不少有它的源码解析,但是采集这块还是不太让人容易理解.今天终于知道怎么,弄的.现在把crawl-urlfilter.txt文件贴出来,让大家一块交流,也给自己备忘录一个。
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file ...
Posted in Java | No Comments »
Friday, November 7th, 2008
有时候使用NUTCH抓取网页的时候,还没运行完成就退出了爬行工作。这时候可能已经抓取了一部分,
可以用以下命令进行索引已经抓取下来的部分:
./nutch updatedb <crawldb> (-dir <segments> | <seg1> <seg2> ...) [-force] [-normalize] [-filter] [-noAdditions]
./nutch invertlinks <linkdb> (-dir <segmentsDir> | <seg1> <seg2> ...) [-force] [-noNormalize] [-noFilter]
./nutch index wdtrade/indexes wdtrade/crawldb/ wdtrade/linkdb wdtrade/segments/segmentdir1 segmentdir2 ...
./nutch dedup wdtrade/indexes/
./nutch readdb wdtrade -stats 查看统计
在nutch-site.xml添加以下配置,
<configuration>
...
<property>
<name>searcher.summary.length</name>
<value>50</value>//默认为20
<description>
The total number of terms to display in a hit summary.
</description>
</property>
...
</configuration>
就可以了.Nutch的默认配置是在nutch-default.xml中设置的,如果您想覆盖它的配置只需在nutch-site.xml中添加相应的配置就好了.
Posted in nutch | No Comments »
Wednesday, October 29th, 2008
试用了好多的中文插件,有CJK,ICTCLAS的还有IK_CAnaylzer的,经过试用测试后,发现最后一个比较好用。CJK基本就是二元分词没有一点意义。本文分两个部分,第一部分是两种插件测试结果的对比,第二部分是如果给nutch增加插件。
第一部分:
================================原文=============================================
他从马上摔下来了。
你马上下来一下。
结合成分子时
薄熙来字词担任商务部长以来,一直兢兢业业。
张华平1995年离开江西鄱阳老家就读于北方工业大学,如今已经是中科院计算所的副研究员,他说ICTCLAS就像是他的孩子一样珍爱;
=================================ICTCLAS==========================================
他 从 马 上 摔 下 来 了 。
你 马上 下来 一下 。
结合 成 分子 时
薄熙来 字 词 担任 商务 部长 以来 , 一直 兢兢业业 。
张华平 1995年 离开 江西 鄱阳 老家 就读 于 北方 工业 大学 , 如今 已经 是 中科院 计算 所 的 副 研究员 , 他 说 ICTCLAS ...
Posted in nutch | No Comments »
Tuesday, October 28th, 2008
Nutch是Apache组织的一个开源项目,利用它用户可以 建立自己内部网的搜索引擎,也可以建立针对整个网络的搜索引擎。
一、Linux下的安装使用
(我使用的操作系统是red hat as4)
1.安装JDK,我安装的是JDK1.5 update11,安装方法到网上搜
2.安装TOMCAT,我安装的是tomcat5.5.23,安装方法到网上搜,输入http://127.0.0.1:8080出现变态猫就ok了,可以进入下一步。
3.到http://www.nutch.org下载Nutch 0.9,2007年4月2日发布的,嘿嘿。
解压与安装
下来的文件是nutch-0.9.tar.gz
运行以下命令以解压:
gunzip nutch-0.9.tar.gz
得到文件:nutch-0.9.tar
再运行以下命令解包:
tar –xvf nutch-0.9.tar
终于得到了nutch-0.9目录,里面包含了nutch代码/文档
测试
进入nutch-0.9目录,执行bin/nutch,
看到下列提示,则说明安装成功:
Usage: nutch COMMAND
where COMMAND is one of :
......
设置待抓取网站
在nucth-0.9目录下建立urls目录(也可以自己命名),在urls目录下建立个文件,我取名为nutch,没有扩展名,扩展名为.txt应该也可以
打开刚才建立的这个名称为nutch的文件,输入待抓取的网站地址,如:
http://www.sunleap.com/
最后的/不能漏掉.
编辑conf目录下的crawl-urlfilter.txt文件,该文件用于设置爬虫的过滤条件
# accept hosts in MY.DOMAIN.NAME
+^http://([a-z0-9]*\.)*MY.DOMAIN.NAME/
修改为:
# accept hosts in MY.DOMAIN.NAME
+^http://([a-z0-9]*\.)*www.sunleap.com/
表示抓取http://([a-z0-9]*\.)*www.sunleap.com/域名下的所有页面
编辑conf目录下的nutch-site.xml文件,该文件用于将爬虫信息告诉被抓取的网站,如果不进行设置nutch不能运行.
该文件默认为这样:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
</configuration>
下面是我修改后的一个例子:
<?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>myfirsttest</value>
<description>HTTP 'User-Agent' request header. MUST ...
Posted in 电脑技术 | No Comments »