Java爬虫——常用的maven依赖

java实现爬虫常用的第三方包:

  • httpclient,for http
  • jsoup,for dom
  • rhino,for js
  • jackson,for json

pom.xml摘录

1<dependencies> 2 3 <!-- simulate web browser --> 4 <dependency> 5 <groupId>org.apache.httpcomponents</groupId> 6 <artifactId>httpclient</artifactId> 7 <version>4.5.7</version> 8 </dependency> 9 10 <!-- parse DOM --> 11 <dependency> 12 <groupId>org.jsoup</groupId> 13 <artifactId>jsoup</artifactId> 14 <version>1.11.3</version> 15 </dependency> 16 17 <!-- jackson --> 18 <dependency> 19 <groupId>com.fasterxml.jackson.core</groupId> 20 <artifactId>jackson-databind</artifactId> 21 <version>2.9.8</version> 22 </dependency> 23 24 <!-- parse javascript --> 25 <dependency> 26 <groupId>org.mozilla</groupId> 27 <artifactId>rhino</artifactId> 28 <version>1.7.10</version> 29 </dependency> 30 31 <!-- simulate client action --> 32 <dependency> 33 <groupId>net.sourceforge.htmlunit</groupId> 34 <artifactId>htmlunit</artifactId> 35 <version>2.33</version> 36 </dependency> 37 38 <!-- upgrade junit to junit4 --> 39 <dependency> 40 <groupId>junit</groupId> 41 <artifactId>junit</artifactId> 42 <version>4.12<!-- default is v3.8.1 --></version> 43 <scope>test</scope> 44 </dependency> 45 46 <!-- log --> 47 <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --> 48 <dependency> 49 <groupId>org.slf4j</groupId> 50 <artifactId>slf4j-api</artifactId> 51 <version>1.7.25</version> 52 </dependency> 53 <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 --> 54 <dependency> 55 <groupId>org.slf4j</groupId> 56 <artifactId>slf4j-log4j12</artifactId> 57 <version>1.7.25</version> 58 <!-- <scope>test</scope> --> 59 </dependency> 60 61 </dependencies>

启用log4j基本配置,在main方法中加入语句:

1public static void main(String[] args) { 2 3 //启用log4j基本配置 4 //不想去写配置文件,可以用Java基本配置 5 BasicConfigurator.configure(); 6 //... 7}
点赞
收藏

评论区

加载中...

相关推荐

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

Java日期时间API系列31

  时间戳是指格林威治时间1970年01月01日00时00分00秒起至现在的总毫秒数,是所有时间的基础,其他时间可以通过时间戳转换得到。Java中本来已经有相关获取时间戳的方法,Java8后增加新的类Instant等专用于处理时间戳问题。 1获取时间戳的方法和性能对比1.1获取时间戳方法Java8以前

java基础知识随身记

2018年11月12日20:51:35一、基础知识:1、JVM、JRE和JDK的区别:JVM(JavaVirtualMachine):java虚拟机,用于保证java的跨平台的特性。  java语言是跨平台,jvm不是跨平台的。JRE(JavaRuntimeEnvironment):java的运行环境,包括jvmjava的核心类

Java爬虫之JSoup使用教程

title:Java爬虫之JSoup使用教程date:201812248:00:000800update:201812248:00:000800author:mecover:https://imgblog.csdnimg.cn/20181224144920712(https://www.oschin

03.Android崩溃Crash库之ExceptionHandler分析

目录总结00.异常处理几个常用api01.UncaughtExceptionHandler02.Java线程处理异常分析03.Android中线程处理异常分析04.为何使用setDefaultUncaughtExceptionHandler前沿上一篇整体介绍了crash崩溃

Java爬虫——常用的maven依赖 - HelloWorld