java的WebCollector爬虫框架

WebCollector主页: https://github.com/CrawlScript/WebCollector

下载:webcollector-版本号-bin.zip将解压后文件夹中的所有jar包添加到工程既可。

接下来看demo
package org.spider.myspider;

import cn.edu.hfut.dmic.webcollector.crawler.BreadthCrawler;

public class MySpider {

	public static void main(String[] args) throws Exception {
		
		BreadthCrawler breadthCrawler = new BreadthCrawler();
		
		breadthCrawler.addSeed("http://www.cmbchina.com/");/*爬取的目标地址*/
		breadthCrawler.addRegex("http://www.cmbchina.com/.*");/*抓取规则,住区该网站下的所有文件*/
		
		breadthCrawler.setRoot("download");/* html、jsp网页、图片、文件被存储在项目中的download文件夹中 */
		breadthCrawler.start(3);/* 进行深度为3的爬取 ,这个深度直接写入值即可*/
	}

}

你可能感兴趣的:(爬虫)