larbin使用说明(ZT)

larbin官方地址http://larbin.sourceforge.net/index-eng.html

一,编译
这也好说,whahahaha,那是!因为从官方网站下下来的代码不能编译通过(linux gcc下)
./configure
make
gcc -O3 -Wall -D_REENTRANT -c -o parse.o parse.c
parse.c:115: error: conflicting types for ‘adns__parse_domain’
internal.h:571: error: previous declaration of ‘adns__parse_domain’ was here
parse.c:115: error: conflicting types for ‘adns__parse_domain’
internal.h:571: error: previous declaration of ‘adns__parse_domain’ was here
gmake[1]: *** [parse.o] 错误 1
gmake[1]: Leaving directory `/home/leo/leo/larbin-2.6.3/adns’
make: *** [all] 错误 2

函数原型和定义不一致这个好改:
打开./adns/internal.h文件,把568-571行直接注释掉就行了。

二,运行
这个就不说了,./larbin就运行了,larbin.conf中先进行配置就可以了,这个配置就不说了。。
运行后可http://host:8081 看运行状态,不错的想法。 larbin.conf中有个:inputPort 1976配置,就是可以运行时增加要抓取的URL,这个想法非常好,可是?怎么加呢?象起初那样http://host:1976那样是不行的,报错???试了好久没结果,最后GDB跟踪了一下,唉,原来直接telnet host 1976进行增加就可以了。后来看到文档里写的亲亲楚楚,晕倒。。。。。

三,结果
哈哈,下班后找了台机子跑了起来,那晚睡觉的时候都梦见自己的搜索引擎赶GOOGLE超BAIDU了,那个兴奋啊。
第二天上班的时候取看结果,发现目录下除了些fifo*文件外什么都没有,那个郁闷。没办法啊,再看文档 How to customize Larbin 发现这么段说明:

The first thing you can define is the module you want to use for ouput. This defines what you want to do with the pages larbin gets. Here are the different options :
DEFAULT_OUTPUT : This module mainly does nothing, except statistics.
SIMPLE_SAVE : This module saves pages on disk. It stores 2000 files per directory (with an index).
MIRROR_SAVE : This module saves pages on disk with the hierarchy of the site they come from. It uses one directory per site.
STATS_OUTPUT : This modules makes some stats on the pages. In order to see the results, seehttp://localhost:8081/output.html.

靠,默认什么都没输出,于是认真的看了官方网站上仅有的两个文档,修改了options.h再编译,终于有结果了。

我的option中改了:
SIMPLE_SAVE 简单输出一个目录两千个文件,包含索引。
CGILEVEL=0 处理服务器端程序,也就是但url中包含? & = 之类的querString时也处理。
NO_DUP
其余可根据各自需要修改,详见: How to customize Larbin 一文。

四,问题

在使用过程中发现,在抓网页的时候,如果URL中包含未编码(encodurl)中文时,无法抓取,简单的看了一下在:src/utils/url.cc中的fileNormalize 有涉及。于是写了个encodurl函数加在url类的构造函数里,问题就解决了。