zoukankan      html  css  js  c++  java
  • nucht1.2二次开发增量采集

    主要参考资料
    1 http://caols.diandian.com/post/2012-06-05/40028026285
    2 http://blog.csdn.net/witsmakemen/article/details/7799546
    3 AdaptiveFetchSchedule 类的文档阅读
    
    关键属性解析:Interval
    1 InjectMapper中 interval = jobConf.getInt("db.fetch.interval.default", 2592000); 
    2 int customInterval = interval; customInterval = Integer.parseInt(metavalue); 或者从URL的interval中设置
    3 CrawlDatum datum = new CrawlDatum(CrawlDatum.STATUS_INJECTED,customInterval); 被放入CrawlDataum
    4 CrawlDb update() 中的  CrawlDbReducer 中的 
    result = schedule.setFetchSchedule((Text)key, result, prevFetchTime,prevModifiedTime, fetch.getFetchTime(), fetch.getModifiedTime(), modified);
    5 schedule默认是调用 DefaultFetchSchedule  这里可以设置下一次采集的日期,方法是:设置索引页过期时间1800 (半小时) 设置 内容页过期时间(7776000 90天)
    
    在nutch-default.xml中添加:
    
        <property>
      <name>db.fetch.interval.default</name>
      <value>86400</value>
      <description>this usage change to be the interval of index page
      this property has wasted by wqj 2013-1-18 The default number of seconds between re-fetches of a page (30 days).
      </description>
    </property>
    
    <property>
      <name>db.fetch.interval.content</name>
      <value>7776000</value>
      <description>interval for content page ,default is  (90 days).
      </description>
    </property>
    
    
            /* modify time :2013-01-18 author wqj */
            Configuration confCurrent=super.getConf();
            int interval_index= confCurrent.getInt("db.fetch.interval.default", 86400);//默认为24小时
            int interval_content=confCurrent.getInt("db.fetch.interval.content", 7776000);//默认为90天
            String regi = datum.getMetaData().get(new Text("regi")).toString();
            if (url.toString().matches(regi)) {
                datum.setFetchInterval(interval_index);
            } else {
                datum.setFetchInterval(interval_content);
            }
            datum.setFetchTime(fetchTime + (long) datum.getFetchInterval()
                    * 1000);
            datum.setModifiedTime(modifiedTime);
            return datum;
    
    
    采集时间 2013-1-18 1430 左右
    http://glcx.moc.gov.cn/CsckManageAction/cxckMoreInfo.do?byName=lkbs_newRoad&page=9    Version: 7
    Status: 2 (db_fetched)
    Fetch time: Fri Jan 18 14:59:53 CST 2013     这里的采集月份依然是1月份 但是也加了 半小时了 
    Modified time: Thu Jan 01 08:00:00 CST 1970
    Retries since fetch: 0
    Retry interval: 1800 seconds (0 days)
    
    http://glcx.moc.gov.cn/CsckManageAction/cxckInformationAction.do?infoId=8a8181d532b43eb40132b9076dd20253    Version: 7
    Status: 2 (db_fetched)
    Fetch time: Thu Apr 18 14:26:26 CST 2013            采集月份是2013 1月份 这里 fetchtime 变为了 4月份 说明这个时间是加上 Retry interval的
    Modified time: Thu Jan 01 08:00:00 CST 1970
    Retries since fetch: 0
    Retry interval: 7776000 seconds (90 days)
    Score: 0.009259259
    Signature: e901870589199bb918c45c9c9fad0782
    
    通过上述可以看出
    fetchTime 事实上在上一次 采集的时候 已经计算好了
    下一次将直接从 CrawlerDb中  读取<当前时间的URL 进行采集   
    
    引申:
    如果想查看内容页 更新 比方一段时间后内容更改了,但是啊  我们那边是用 URL 布隆过滤器去重的,即使有更新也不会反应在数据库里啊
    是不是 RegexDumpParser 在这里 观察一下  更新的网页的  DUMP文件是否有什么特殊标记,如果是  有更新内容的文章  则改为UPDATE呢
  • 相关阅读:
    多线程中,上锁的理解
    sql server 2008 联机丛书
    序列化是线程安全的么
    对象化下的编程——字段
    Dic实现工厂模式
    design principle:java 回调与委派/委托机制(转)
    风筝数据结构学习笔记(2)后序遍历二叉树(非递归)
    风筝数据结构学习笔记(1)利用链式存储结构和递归构建二叉树
    吕震宇老师《设计模式系列》
    吕震宇老师《设计模式随笔系列》
  • 原文地址:https://www.cnblogs.com/i80386/p/2988312.html
Copyright © 2011-2022 走看看