资源简介
正方教务系统数据抓取(含验证码识别),模拟登录,抓取课表,考试成绩,考试安排,个人信息。并且提供了Json Api接口可供客户端调用。
代码片段和文件信息
package com.nami;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
public class Test {
public static void post(String usernumber String pwd String role) {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(“http://localhost:8080/WhxyJw/baseServlet/JsonOutLogin“);
HttpResponse response = null;
List params = new ArrayList();
params.add(new BasicNameValuePair(“usernumber“ usernumber));
params.add(new BasicNameValuePair(“pwd“ pwd));
params.add(new BasicNameValuePair(“role“ role));
try {
httppost.setEntity(new UrlEncodedFormEntity(params));
response = httpclient.execute(httppost);
System.out.println(“接口:“+ response.getStatusLine().toString());
if(“HTTP/1.1 200 OK“.equals(response.getStatusLine().toString())){
String result = EntityUtils.toString(response.getEntity() “utf-8“);
System.out.println(result);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void postGrade(String username String usernumber String urlcode
String ddlXN String ddlXQ String btn_zcj) {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(“http://localhost:8080/WhxyJw/JwServlet/JsonOutGrade“);
HttpResponse response = null;
List params = new ArrayList();
params.add(new BasicNameValuePair(“username“ username));
params.add(new BasicNameValuePair(“usernumber“ usernumber));
params.add(new BasicNameValuePair(“urlcode“ urlcode));
params.add(new BasicNameValuePair(“ddlXN“ ddlXN));
params.add(new BasicNameValuePair(“ddlXQ“ ddlXQ));
params.add(new BasicNameValuePair(“btn_zcj“ btn_zcj));
try {
httppost.setEntity(new UrlEncodedFormEntity(params));
response = httpclient.execute(httppost);
//System.out.println(“接口:“+ response.getStatusLine().toString());
if(“HTTP/1.1 200 OK“.equals(response.getStatusLine().toString())){
String result = EntityUtils.toString(response.getEntity() “utf-8“);
System.out.println(result);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void postTimetable(String username String usernumber String urlcode) {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(“http://localhost:8080/WhxyJw/JwServlet/JsonOutTimetable“);
HttpResponse response = null;
List params = new ArrayList();
params.add(new BasicNameValuePair(“username“ username));
params.a
- 上一篇:ansys经典教程20例
- 下一篇:Maxwell静电场中同轴电缆的3D仿真
评论
共有 条评论