webcollector是一个开源的Java网络爬虫框架。最近的爬虫改用java写了,对这一周的工作进行简要总结。对于内部机制了解不深入,主要侧重在应用。

一、环境搭建

  需要安装一个webcollector的jar包,从官网上下载bin文件,解压,根据不同IDE的安装方式进行安装即可。

  https://github.com/CrawlScript/WebCollector

  关于使用,官网上提供了很多的例子,从GitHub上将整个Webcollector的工程下载下来,参照进行编码。

  Webcollector应用(一)

  我直接在官方提供的工程上面建了个文件夹,进行编码。

二、基本使用

  两个class,一个Model,一个抓取

  1、Model类——封装了要抓取的那些字段

 1 package cn.edu.hfut.dmic.webcollector.example.myCrawler.test;
 2 
 3 public class TongModel {
 4     String fullName;
 5     String shortName;
 6     String time;
 7     public String getFullName() {
 8         return fullName;
 9     }
10 
11     public void setFullName(String fullName) {
12         this.fullName = fullName;
13     }
14 
15     public String getShortName() {
16         return shortName;
17     }
18 
19     public void setShortName(String shortName) {
20         this.shortName = shortName;
21     }
22 
23     public String getTime() {
24         return time;
25     }
26 
27     public void setTime(String time) {
28         this.time = time;
29     }
30 }
View Code

相关文章:

  • 2021-04-04
  • 2021-11-17
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2021-05-06
  • 2021-04-17
  • 2022-12-23
  • 2021-04-29
相关资源
相似解决方案