Larbin的安装与配置

由于以前没有接触过网络爬虫,对网络爬虫仅仅停留在听过,具体怎么样不天清楚。正好,需要完成某作业,我想这样可以了解了解这方面的知识了。

 
   从网上看了很多网络爬虫,最后,选择了Larbin,因为这是用C++写的,对于源码可以相对比较容易的看懂。
   
   现在,把安装过程和相关的配置记录下来,省的以后用的时候还得查找资料。
 
一、Larbin的安装
 
   从官网上获取源码包:larbin.2.6.3。
   
   现在开始正式安装。
   1、 ./configure
   2、 gmake debug(debug:调试安装,当然,也可以不使用该选项)
 
   但是,安装过程中出现了错误,如下所示。
 
   1> 错误1
  1. parse.c:115: error: conflicting types for 'adns__parse_domain'
  2. internal.h:571: error: previous declaration of 'adns__parse_domain' was here
  3. parse.c:115: error: conflicting types for 'adns__parse_domain'
  4. internal.h:571: error: previous declaration of 'adns__parse_domain' was here
  5. gmake[1]: *** [parse.o] 错误 1
  6. gmake[1]: Leaving directory `/home/leo/leo/larbin-2.6.3/adns'
  7. make: *** [all] 错误 2
    解决方案:
    函数原型和定义不一致这个好改:
    打开./adns/internal.h文件,把568-571行直接注释掉就行了。
 
    2> 错误2  
  1. -bash:./configure:command not found

    解决方案:

    我上网查了查,执行了命令:chmod +x configure,然后就可以了。不晓得为什么。
 
二、Larbin的配置说明
 
1、larbin.conf文件

  1. ###############################################
  2. //客户端标记,当对其他网站抓取时,被抓取的网站知道是什么抓取的
  3.  
  4. UserAgent larbin_2.6.3
  5. ############################################
  6. # What are the inputs and ouputs of larbin
  7. # port on which is launched the http statistic webserver
  8. # if unset or set to 0, no webserver is launched
  9. //用于运行的http web服务器的端口号(larbin运行时访问http://localhost:8081/,设置为http_port 8081).如果将端口设为0,则不会启动web服务器。通过这个可以查看爬行结果。
  10.  
  11. httpPort 8081
  12. # port on which you can submit urls to fetch
  13. # no input is possible if you comment this line or use port 0
  14.  
  15. //你要爬取url的端口。如果注释掉或设为0,则可能没有任何输入。如果通过手动或者程序提交爬取的//urls,则必须练就到计算机的TCP端口1976,即设为:inputPort 1976,可以添加爬行的url。
  16.  
  17. #inputPort 1976
  18. ############################################
  19. # parameters to adapt depending on your network
  20. # Number of connexions in parallel (to adapt depending of your network speed)
  21. //并行爬取网页的数量,根据自己环境的网速调解,如果超时太多,则要降低这个并行数量
  22.  
  23. pagesConnexions 100
  24. # Number of dns calls in parallel
  25. //并行DNS域名解析的数量。
  26.  
  27. dnsConnexions 5
  28. # How deep do you want to go in a site
  29. //对一个站点的爬取的深度
  30.  
  31. depthInSite 5
  32. # do you want to follow external links
  33. //不允许访问外部链接。如果设置则只可访问同一主机的连接
  34. #noExternalLinks
  35. # time between 2 calls on the same server (in sec) : NEVER less than 30
  36. //访问同一服务器的时间间隔。不可低于30s,建议60s
  37. waitDuration 60
  38. # Make requests through a proxy (use with care)
  39. //是否用代理连接,如果用,则要设置、可以不用尽量不要用,这个选项要谨慎
  40. #proxy www 8080
  41. ##############################################
  42. # now, let's customize the search
  43. # first page to fetch (you can specify several urls)
  44. //开始爬取的URL
  45. startUrl http://slashdot.org/
  46. # Do you want to limit your search to a specific domain ?
  47. # if yes, uncomment the following line
  48. //这个选项设置了,则不可以爬行指定的特殊域名
  49. #limitToDomain .fr .dk .uk end
  50. # What are the extensions you surely don't want
  51. # never forbid .html, .htm and so on : larbin needs them
  52. //不想要的扩展名文件。一定不要禁止.html、.htm.larbin爬取的就是它们。禁止也是无效的
  53. forbiddenExtensions
  54. .tar .gz .tgz .zip .Z .rpm .deb
  55. .ps .dvi .pdf
  56. .png .jpg .jpeg .bmp .smi .tiff .gif
  57. .mov .avi .mpeg .mpg .mp3 .qt .wav .ram .rm
  58. .jar .java .class .diff
  59. .doc .xls .ppt .mdb .rtf .exe .pps .so .psd
  60. end
2、options.h
 
2.1 输出模式

  1. // Select the output module you want to use
  2. //默认模式。什么也不输出,不要选择这个
  3. #define DEFAULT_OUTPUT // do nothing...
  4. //简单保存,存在save/dxxxxx/fyyyyy文件中,每个目录下2000个文件
  5. //#define SIMPLE_SAVE // save in files named save/dxxxxxx/fyyyyyy
  6. //镜像方式存储。按网页的层次存储,可以作为网页的字典。
  7. //#define MIRROR_SAVE // save in files (respect sites hierarchy)
  8. //状态输出。在网页上进行状态输出,可以查看http://localhost:8081/output.html查看结果
  9. //#define STATS_OUTPUT // do some stats on pages
    这些模式被定制在src/type.h中,可以在src/interf/useroutput.cc中定制自己的输出模式。
   这个文件中还有很多相关配置,更改后,需要重新编译。
  
2.2 特定查询
 
  1. // Set up a specific search
  2. //设置特定的查询
  3. //#define SPECIFICSEARCH
  4. //内容类型
  5. //#define contentTypes ((char *[]) { "audio/mpeg", NULL })
  6. //文件扩展。用于查询速度,不涉及类型,类型由上一个决定
  7. //#define privilegedExts ((char *[]) { ".mp3", NULL })

 

2.3 设置完要设置特定文件的管理

  1. #define DEFAULT_SPECIFIC //默认管理方式。 作为html有限制除了被解析。
  2. // 存储特定文件。 允许将文件存储在硬盘上 文件可以很大在src/types.h 可以具体设置。
  3. #define SAVE_SPECIFIC 
  4. //动态存储模式。对于较大的文件动态的分配buffer。
  5. #define DYNAMIC_SPECIFIC 
     可以通过"src/fetch/specbuf.cc" and "src/fetch/specbuf.h" 定义特定文件的管理方式。
 
2.4 你要爬虫做什么

  1. //不继续子链接。不设置此项则html页不被解析链接也不会爬子链接。通过输入系统添加url时很有用
  2. #define FOLLOW_LINKS
  3.  
  4. //每个网页中包含的子链接的列表。在"useroutput.cc" 用page->getLinks() 访问此信息。
  5. #define LINKS_INFO 
  6. //url标签。设置此项url有一个int(默认为0)。使用输入系统统时应该给定一个int。可以通过其获取u//rl。可以重定向。
  7. #define URL_TAGS
  8.  
  9. //不允许重复。如果设置则遇到相同网页但已遇到过时则不管。
  10. #define NO_DUP
  11. //结束退出。没有url可爬取时是否退出。设置则退出。
  12. #define EXIT_AT_END 
  13. //抓取网页中的图片。设置了此项则要更新larbin.conf中禁止项。
  14. #define IMAGES
  15. //抓取任何类型网页不管其的类型。设置要更新larbin.conf。
  16. #define ANYTYPE
  17. //要larbin管理cookies。只简单实现但很有用。
  18. #define COOKIES
2.5 其他选项说明

  1. #define CGILEVEL 1       //定于选项及其参数。用于对爬行的url的限制。
  2. #define MAXBANDWIDTH 200000  //larbin使用的带宽大小。不设置则不限带宽。
  3. #define DEPTHBYSITE          //当url链接到其他站点时新rul的深度是已被初始化的。
2.6 效率和特征

  1. //是否为输入制定一个专用线程。当你在useroutput.cc定义自己的代码时必须设置此项。
  2. #define THREAD_OUTPUT
  3. //重启位置记录表。设置此项时可以从上次终止处继续爬取。使用-scratch 选项从上次结束处重启。
  4. #define RELOAD
2.7 Larbin怎么工作

  1. #define NOWEBSERVER   //不启动服务器。不运行线程时很有用
  2. #define GRAPH//是否在状态也使用柱状图。
  3. #define NDEBUG//不启动调试信息。
  4. #define NOSTATS//不启动状态输出。
  5. #define STATS//启动状态输出。运行时每个一段时间就会输出抓取的状态
  6. #define BIGSTATS//在标准输出上显示每个被抓去的网页名字。会降低larbin速度
  7. #define CRASH//用于报告严重的bugs用。以gmake debug模式编译时使用。
   
 
   备注:关于larbin配置文件详解,转自: http://terry831010.blog.163.com/blog/static/69161171201227111635189/
   感谢作者。
 
 
 
 
梦醒潇湘love
      2012/10/30 22:07

 

转载于:https://www.cnblogs.com/shaoweinan/p/3520841.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值