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 主页
l HTMLParser 主页
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() ); |