使用Forest+Jsoup对正方教务系统登陆(Java实现)
什么是 Forest?
Forest 是一个开源的 Java HTTP 客户端框架,它能够将 HTTP 的所有请求信息(包括 URL、Header 以及 Body 等信息)绑定到您自定义的 Interface 方法上,能够通过调用本地接口方法的方式发送 HTTP 请求。
开源地址:Gitee地址
官网:http://forest.dtflyx.com/
项目环境:
基于SpringBoot的引入(主要因为官网有SpringBoot的starter)的Pom.xml代码:
<dependencies>
<!-- SpringBoot的引入-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Jsoup的Xpath引入-->
<dependency>
<groupId>cn.wanghaomiao</groupId>
<artifactId>JsoupXpath</artifactId>
<version>2.2</version>
</dependency>
<!--Forest的引入-->
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>forest-spring-boot-starter</artifactId>
<version>1.5.11</version>
</dependency>
</dependencies>
这里还引入了一个Gitee上的自动识别教务系统的验证码的项目
这个项目比较老了,但可以自动识别验证码并且返回验证码所携带的cookie,我这个项目也是基于它的二次开发
地址:https://gitee.com/suseonline/OrcJwglCode