root权限:html
sudo nautilusjava
一:准备工做:
1.
安装gcc: sudo apt-get install gcc
安装g++: sudo apt-get install g++
安装xutils-dev:sudo apt-get install xutils-dev
安装make: sudo apt-get install make
2.
到官网下载larbin.tar.gz
安装:
1.解压larbin的包:
2.进入到 larbin目录下:cd /home/shaoweinan/larbin-2.6.3
3.修改adns文件夹的internal.h文件569-571行:
adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
vbuf vb, parsedomain_flags flags,
const byte dgram, int dglen, intcbyte_io, int max);
改成:
adns_status adns__parse_domain(adns_state ads, int serv, adns_query qu,
vbuf vb, adns_queryflags flags,
const byte dgram, int dglen, intcbyte_io, int max);
4.复制/usr/include/c++/的iostream文件到larbin的src目录下,并更名为iostream.h,在文件中添加一句using namespace std;
5.修改编译选项配置:vi options.h
修改输出选项: 将//#define SIMPLE_SAVE前的//取消掉,在#define DEFAULT_OUTPUT前加//
(注释的其实至关清楚的)
6.检查系统是否知足编译要求:./configure
7.编译:make
8.运行:进入larbin目录:./larbin
9.ctrl+c 终止程序ios
2、Larbin的配置说明
larbin的正常使用须要配置options.h和larbin.config这两个文件。若是修改了options.h,则须要从新make一下。若是只修改了larbin.conf则不须要从新make。
一、larbin.conf文件c++
###############################################
//客户端标记,当对其余网站抓取时,被抓取的网站知道是什么抓取的web
UserAgent larbin_2.6.3服务器
############################################
# What are the inputs and ouputs of larbin
# port on which is launched the http statistic webserver
# if unset or set to 0, no webserver is launchedcookie
//用于运行的http web服务器的端口号(larbin运行时访问http://localhost:8081/,设置为http_port 8081).若是将端口设为0,则不会启动web服务器。经过这个能够查看爬行结果。less
httpPort 8081dom
# port on which you can submit urls to fetch
# no input is possible if you comment this line or use port 0fetch
//你要爬取url的端口。若是注释掉或设为0,则可能没有任何输入。若是经过手动或者程序提交爬取的//urls,则必须练就到计算机的TCP端口1976,即设为:inputPort 1976,能够添加爬行的url。
#inputPort 1976
############################################
# parameters to adapt depending on your network
# Number of connexions in parallel (to adapt depending of your network speed)
//并行爬取网页的数量,根据本身环境的网速调解,若是超时太多,则要下降这个并行数量
pagesConnexions 100
# Number of dns calls in parallel
//并行DNS域名解析的数量。
dnsConnexions 5
# How deep do you want to go in a site
//对一个站点的爬取的深度
depthInSite 5
# do you want to follow external links
//不容许访问外部连接。若是设置则只可访问同一主机的链接
#noExternalLinks
# time between 2 calls on the same server (in sec) : NEVER less than 30
//访问同一服务器的时间间隔。不可低于30s,建议60s
waitDuration 60
# Make requests through a proxy (use with care)
//是否用代理链接,若是用,则要设置、能够不用尽可能不要用,这个选项要谨慎
#proxy www 8080
##############################################
# now, let's customize the search
# first page to fetch (you can specify several urls)
//开始爬取的URL
startUrl http://slashdot.org/
# Do you want to limit your search to a specific domain ?
# if yes, uncomment the following line
//这个选项设置了,则不能够爬行指定的特殊域名
#limitToDomain .fr .dk .uk end
# What are the extensions you surely don't want
# never forbid .html, .htm and so on : larbin needs them
//不想要的扩展名文件。必定不要禁止.html、.htm.larbin爬取的就是它们。禁止也是无效的
forbiddenExtensions
.tar .gz .tgz .zip .Z .rpm .deb
.ps .dvi .pdf
.png .jpg .jpeg .bmp .smi .tiff .gif
.mov .avi .mpeg .mpg .mp3 .qt .wav .ram .rm
.jar .java .class .diff
.doc .xls .ppt .mdb .rtf .exe .pps .so .psd
end
二、options.h
2.1 输出模式
// Select the output module you want to use
//默认模式。什么也不输出,不要选择这个
#define DEFAULT_OUTPUT // do nothing...
//简单保存,存在save/dxxxxx/fyyyyy文件中,每一个目录下2000个文件
//#define SIMPLE_SAVE // save in files named save/dxxxxxx/fyyyyyy
//镜像方式存储。按网页的层次存储,能够做为网页的字典。
//#define MIRROR_SAVE // save in files (respect sites hierarchy)
//状态输出。在网页上进行状态输出,能够查看http://localhost:8081/output.html查看结果
//#define STATS_OUTPUT // do some stats on pages
这些模式被定制在src/type.h中,能够在src/interf/useroutput.cc中定制本身的输出模式。
这个文件中还有不少相关配置,更改后,须要从新编译。
2.2 特定查询
// Set up a specific search
//设置特定的查询
//#define SPECIFICSEARCH
//内容类型
//#define contentTypes ((char *[]) { "audio/mpeg", NULL })
//文件扩展。用于查询速度,不涉及类型,类型由上一个决定
//#define privilegedExts ((char *[]) { ".mp3", NULL })
2.3 设置完要设置特定文件的管理
#define DEFAULT_SPECIFIC //默认管理方式。 做为html有限制除了被解析。
// 存储特定文件。 容许将文件存储在硬盘上 文件能够很大在src/types.h 能够具体设置。
#define SAVE_SPECIFIC
//动态存储模式。对于较大的文件动态的分配buffer。
#define DYNAMIC_SPECIFIC
能够经过"src/fetch/specbuf.cc" and "src/fetch/specbuf.h" 定义特定文件的管理方式。
2.4 你要爬虫作什么
//不继续子连接。不设置此项则html页不被解析连接也不会爬子连接。经过输入系统添加url时颇有用
#define FOLLOW_LINKS
//每一个网页中包含的子连接的列表。在"useroutput.cc" 用page->getLinks() 访问此信息。
#define LINKS_INFO
//url标签。设置此项url有一个int(默认为0)。使用输入系通通时应该给定一个int。能够经过其获取u//rl。能够重定向。
#define URL_TAGS
//不容许重复。若是设置则遇到相同网页但已遇到过期则无论。
#define NO_DUP
//结束退出。没有url可爬取时是否退出。设置则退出。
#define EXIT_AT_END
//抓取网页中的图片。设置了此项则要更新larbin.conf中禁止项。
#define IMAGES
//抓取任何类型网页无论其的类型。设置要更新larbin.conf。
#define ANYTYPE
//要larbin管理cookies。只简单实现但颇有用。
#define COOKIES
2.5 其余选项说明
#define CGILEVEL 1 //定于选项及其参数。用于对爬行的url的限制。
#define MAXBANDWIDTH 200000 //larbin使用的带宽大小。不设置则不限带宽。
#define DEPTHBYSITE //当url连接到其余站点时新rul的深度是已被初始化的。
2.6 效率和特征
//是否为输入制定一个专用线程。当你在useroutput.cc定义本身的代码时必须设置此项。
#define THREAD_OUTPUT
//重启位置记录表。设置此项时能够从上次终止处继续爬取。使用-scratch 选项从上次结束处重启。
#define RELOAD
2.7 Larbin怎么工做
#define NOWEBSERVER //不启动服务器。不运行线程时颇有用
#define GRAPH //是否在状态也使用柱状图。
#define NDEBUG //不启动调试信息。
#define NOSTATS //不启动状态输出。
#define STATS //启动状态输出。运行时每一个一段时间就会输出抓取的状态。
#define BIGSTATS //在标准输出上显示每一个被抓去的网页名字。会下降larbin速度
#define CRASH //用于报告严重的bugs用。以gmake debug模式编译时使用。
3、larbin的配置简洁版
larbin的正常使用须要配置options.h和larbin.config这两个文件。若是修改了options.h,则须要从新make一下。若是只修改了larbin.conf则不须要从新make。
下面报一下个人两个配置文件里的内容
larbin.conf
httpPort 8099
inputPort 1976
pagesConnexions 100
dnsConnexions 5
waitDuration 60
startUrl http://qdbje.blog.163.com (网上文章中有使用www.baidu.com做为startUrl的,但个人实验代表以此做为种子url,larbin爬不到结果……)
limitToDomain .com .cn .hk end
forbiddenExtensions.tar .gz .tgz .zip .Z .rpm .deb
.ps .dvi .pdf.png .jpg .jpeg .bmp .smi .tiff .gif
.mov .avi .mpeg .mpg .mp3 .qt .wav .ram .rm
.jar .java .class .diff
.doc .xls .ppt .mdb .rtf .exe .pps .so .psd
end
options.h
#ifndef LARBIN_CONFIG
#define LARBIN_CONFIG
#include "config.h"
#define SIMPLE_SAVE
#define FOLLOW_LINKS
#define CGILEVEL 1
#define DEPTHBYSITE
#define RELOAD
#define CRASH
#endif
4、Larbin的使用
运行 ./larbin (或“nohup ./larbin &”,可以使larbin在后台运行)
停止 Ctrl+C
重起 ./larbin -scratch
备注:关于larbin配置文件详解,转自:http://terry831010.blog.163.com/blog/static/69161171201227111635189/ 感谢做者。