Esempio n. 1
0
 /**
  * 得到处于活跃状态的网页爬虫
  *
  * @return
  */
 public static List<Crawler> getActiveWebCrawlerList() {
   List<Crawler> activeCrawlerList = new ArrayList<Crawler>();
   for (Crawler crawler : DataCache.activeCrawlerList) {
     if (crawler.getCrawlerType().indexOf("网页爬虫") != -1) {
       activeCrawlerList.add(crawler);
     }
   }
   return activeCrawlerList;
 }
Esempio n. 2
0
 /**
  * 选择一个全网爬虫
  *
  * @return
  */
 public static Crawler getWebCrawler() {
   if (activeCrawlerList != null) {
     for (Crawler crawler : activeCrawlerList) {
       if (crawler.getCrawlerType().contains("网爬虫")) {
         return crawler;
       }
     }
   }
   return null;
 }
Esempio n. 3
0
 public static synchronized void initCrawler() {
   activeCrawlerList = crawlerService.find("from Crawler where status = 1 and isDeath = 1");
   detahCrawlerList = crawlerService.find("from Crawler where status = 1 and isDeath = 0");
   List<Crawler> crawlerList = crawlerService.find("from Crawler ");
   crawlerMap.clear();
   if (crawlerList != null) {
     for (Crawler crawler : crawlerList) {
       crawlerMap.put(crawler.getCode(), crawler);
       DataBase dataBase =
           dataBaseService.getDao().getTemplate().get(DataBase.class, crawler.getDatabaseId());
       crawler.setDataBase(dataBase);
     }
   }
 }