开源网络爬虫WebCollector的demo
1、环境:jdk7+eclipse mars
2、WebCollector开源网址https://github.com/CrawlScript/WebCollector
下载webcollector-2.26-bin.zip,解压文件夹引入所有jar包到工程。
3、demo源码:
/*** Demo of crawling web by webcollector * @author fjs*/
package com;
import cn.edu.hfut.dmic.webcollector.model.CrawlDatums;
import cn.edu.hfut.dmic.webcollector.model.Page;
import cn.edu.hfut.dmic.webcollector.plugin.berkeley.BreadthCrawler;
import org.jsoup.nodes.Document;public class demo extends BreadthCrawler {/*** @param crawlPath crawlPath is the path of the directory which maintains* information of this crawler* @param autoParse if autoParse is true,BreadthCrawler will auto extract* links which match regex rules from page*/public demo(String crawlPath, boolean autoParse) {super(crawlPath, autoParse);/*start page*/this.addSeed("http://guangzhou.qfang.com");/*fetch url like the value by setting up RegEx filter rule */this.addRegex(".*");/*do not fetch jpg|png|gif*/this.addRegex("-.*\\.(jpg|png|gif).*");/*do not fetch url contains #*/this.addRegex("-.*#.*");}@Overridepublic void visit(Page page, CrawlDatums next) {String url = page.getUrl();Document doc = page.getDoc();System.out.println(url);System.out.println(doc.title());/*If you want to add urls to crawl,add them to nextLink*//*WebCollector automatically filters links that have been fetched before*//*If autoParse is true and the link you add to nextLinks does not match the regex rules,the link will also been filtered.*///next.add("http://gz.house.163.com/");}public static void main(String[] args) throws Exception {demo crawler = new demo("path", true);crawler.setThreads(50);crawler.setTopN(100);//crawler.setResumable(true);/*start crawl with depth 3*/crawler.start(3);}
}
4、实际应用中,对page进行解析抓取网页内容。
开源网络爬虫WebCollector的demo相关推荐
- 调研目前主要的开源网络爬虫,并且说明各自的特点、局限性以及相互之间的区别
PB10210016徐波-第一次作业 Chp.2 Web Crawling 调研目前主要的开源网络爬虫,并且说明各自的特点.局限性以及相互之间的区别.提交方式:word打印稿. 答:网络蜘蛛(Web ...
- java heritrix_Heritrix 和 Nutch 比较与分析(java开源网络爬虫)
Heritrix项目介绍 Heritrix工程始于2003年初,IA的目的是开发一个特殊的爬虫,对网上的资源进行归档,建立网络数字图书馆.在过去的6年里,IA已经建立了400TB的数据. IA期望他们 ...
- Java网络爬虫简介
一.爬虫介绍 1. 概述 网络爬虫(Web crawler)也叫网络蜘蛛(Web spide)自动检索工具(automatic indexer),是一种"自动化浏览网络"的程序,或 ...
- 开发网络爬虫应该怎样选择爬虫框架?
2019独角兽企业重金招聘Python工程师标准>>> 有些人问,开发网络爬虫应该选择Nutch.Crawler4j.WebMagic.scrapy.WebCollector还是其他 ...
- 揭秘Java网络爬虫程序原理
随着互联网+时代的来临,越来越多的互联网企业层出不穷,涉及游戏.视频.新闻.社交.电商.房产.旅游等众多行业.如今互联网成为大量信息的载体,如何有效地从中提取有价值的信息并利用这些信息成为一个巨大的挑 ...
- 网络爬虫(2)-- Java爬虫框架
2019独角兽企业重金招聘Python工程师标准>>> Nutch Nutch属于分布式爬虫,爬虫使用分布式,主要是解决两个问题:1)海量URL管理:2)网速.如果要做搜索引擎,Nu ...
- java 爬虫框架nutch_网络爬虫(2)-- Java爬虫框架
Nutch Nutch属于分布式爬虫,爬虫使用分布式,主要是解决两个问题:1)海量URL管理:2)网速.如果要做搜索引擎,Nutch1.x是一个非常好的选择.Nutch1.x和solr或者es配合,就 ...
- 玩C一定用得到的19款Java开源Web爬虫
网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本.另外一些不常使用的名字还有蚂蚁.自动索引.模拟程序或者蠕 ...
- 最佳免费网络爬虫工具
最佳免费网络爬虫工具有哪些?你是否正在寻找工具来提高你的 SEO 排名.曝光率和转化率?为此,你需要一个网络爬虫工具.网络爬虫是一种扫描互联网的计算机程序.网络蜘蛛.网络数据提取软件和网站抓取程序是互 ...
最新文章
- WINDOWS XP 开始→运行→命令 集锦
- php html实例代码,PHP生成HTML静态页面实例代码
- Caffe学习系列(20):用训练好的caffemodel来进行分类
- 访问被拒绝:“microsoft.web.ui.webcontrols”的解决办法
- 第一个Sprint冲刺第六天
- 【JVM】javap命令行分析揭示boolean的本质的虚拟机指令
- JDK 伪异步编程(线程池)
- LaTeX Cookbook by Eric
- Excel2007中插入页眉和页脚
- 使用Visual Studio Code + Node.js搭建TypeScript开发环境
- Python模块_json pickle模块
- 数学-泰勒展开和拉格朗日
- 常用的项目团队管理方法
- [面面面]搞定计算机面试常见知识点——Java篇
- 外贸邮箱企业邮箱,免费外贸企业邮箱大全,外贸企业邮箱都有哪些?
- 计算机英语中CISC的汉语意思是,CISC是什么意思_CISC在线翻译_读音_用法_例句_含义-查字典网...
- 跨境电商亚马逊2022年再去做亚马逊好做吗
- Android发送短信SMS的编程
- LeetCode - 500 - 键盘行(keyboard-row)
- java生成二维码到文件,java生成二维码转成BASE64