WebCollector 爬虫解析

WebCollector 爬虫解析

  1. WebCollection 爬虫核心类 cn.edu.hfut.dmic.webcollector.crawler.Crawler
	protected int status;  //运行状态 
    public final static int RUNNING = 1;// 运行状态 运行中
    public final static int STOPED = 2; // 运行状态 停止
    protected boolean resumable = false;// 是否中断可恢复,即程序中断是否重新爬取已爬取的网址
    protected int threads = 50;// 爬取的线程树


    protected CrawlDatums seeds = new CrawlDatums(); // 爬区的种子URL集合
    protected CrawlDatums forcedSeeds = new CrawlDatums();// 强制注入 爬区的种子URL集合
    protected Fetcher fetcher;// 爬取任务执行器,管理爬虫线程,调度
    protected int maxExecuteCount = -1; // 设置每个爬取任务的最大执行次数,爬取或解析失败都会导致执行失败。 当一个任务执行失败时,爬虫会在后面的迭代中重新执行该任务,当该任务执行失败的次数超过最大执行次数时,任务生成器会忽略该任务

    protected Executor executor = null;// 实际获得内容并处理的执行器
    protected NextFilter nextFilter = null;// URL爬取后获得的url 过滤器
    protected DBManager dbManager;// 爬取的url存储管理器

其中最重要的方法 开始爬取过程

 /**
     * 开始爬取,迭代次数为depth
     *
     * @param depth 迭代次数
     * @throws Exception 异常
     */
    public void start(int depth) throws Exception {
   
        LOG.info(this.toString());

        //register dbmanager conf
        ConfigurationUtils.setTo(this, dbManager, executor, nextFilter);

        registerOtherConfigurations();

		// 这里 如果不是可恢复的 清理数据管理器
        if (!resumable) {
   
            if (dbManager.isDBExists()) {
   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值