Heritrix资源、绑定IP、启动参数、中文乱码

Heritrix 资源

网络上的 Heritrix 中文资源比较少,整理一下:

 

中文:

l          《开发自己的搜索引擎 Lucene 2.0 + Heritrix 》作者邱哲 & 符滔滔的 BLOG

http://lucenebook.spaces.live.com/

 

l          《开发自己的搜索引擎 Lucene 2.0 + Heriterx 第十章扩展 Heritrix 试读章节

( 可以考虑开发的,比较有用 )

http://book.csdn.net/bookfiles/312/10031212848.shtml

 

l          Heritrix 笔记

http://wiki.hoodong.com/wiki/jRwNBCFgWA1dYB0NC

 

l          Heritrix crawler vs Nutch crawler

http://www.dbanotes.net/web/heritrix_crawler_vs_nutch_crawler.html

 

l          天下维客 - 爬虫程序

http://www.allwiki.com/wiki/Heritrix#Heritrix.E7.9A.84.E5.B1.80.E9.99.90

 

英文:

l          Heritrix 主页

http://crawler.archive.org/

 

l          HTMLParser 主页

http://htmlparser.sourceforge.net/

 
 

Heritrix 绑定主机 IP

关键字: Heritrix 127.0.0.1 IP 主机

 

Heritrix 默认绑定的 IP 127.0.0.1

org.archive.crawler.Heritrix

 

final private static Collection<String> LOCALHOST_ONLY =

     Collections.unmodifiableList(Arrays.asList(new String[] { "127.0.0.1" }));

private static Collection<String> guiHosts = LOCALHOST_ONLY;

 

protected static String doCmdLineArgs(final String [] args)

throws Exception {

    // Now look at options passed.

        for (int i = 0; i < options.length; i++) {

            switch(options[i].getId()) {

                …

                case 'b':

                    Heritrix.guiHosts = parseHosts(options[i].getValue());

                    break;

                …

                default:

                    assert false: options[i].getId();

            }

        }

}

 

首先定义了默认 IP 127.0.0.1 ,然后赋给 guiHost 主机变量。当指定 -b --bind 参数时,才会把指定的 IP 赋给主机变量。

另外,中间还有一步参数处理,对于 --xxxx 参数会转为 -x 的形式统一处理,所以 --bind -b 有一样的效果。

 

Heritrix 启动参数

关键字: Heritrix 启动 参数 bind admin properties

 

Heritrix 的启动参数,除了 --bind 外,都可以在 heritrix.properties 设置,而不用每次都在命令行中输入。

如常用的 --port, --admin 等。

 

heritrix.cmdline.admin = admin:admin

heritrix.cmdline.port = 8080

heritrix.cmdline.run = false

heritrix.cmdline.nowui = false

heritrix.cmdline.order =

heritrix.cmdline.jmxserver = false

heritrix.cmdline.jmxserver.port = 8081

 

关于 Heritrix Extractor 中文乱码

关键字: Heritrix 中文 乱码 GB2312 Extractor

 

继承从 org.archive.crawler.extractor.Extractor 的子类,在extract 方法中可以从参数CrawlURI 中取出要解析的内容。

 

curi.getHttpRecorder().getReplayCharSequence.toString()

 

有中文时,不做处理会输出乱码。可以在取到的HttpRecorder 后设置编码:

 

HttpRecorder hr = curi.getHttpRecorder();

if ( hr == null ) {

    throw new IOException( "Why is recorder null here?" );

}

hr.setCharacterEncoding( "gb2312" );

cs = hr.getReplayCharSequence();

System.out.println( cs.toString() );

 

 

 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值