JAVA uses HttpClient to simulate logging into the square educational administration system, crawling student status information and curriculum scores, etc., super detailed login analysis and code annotations

 

table of Contents

Foreword

analysis

Code

The first GET

POST login

The second Get

The third GET

Fourth GET

The fifth GET

test

Complete code


 

Foreword

Recently, I am working on an APP. I need to obtain the information of the educational administration system of our school, the Wuhan University of Textiles and Waters, the Royal Water and Power Outage College, to arrange courses. The rogue school has blocked the default login page of the square educational administration system and cannot use the existing interface. Using Firefox to capture packets, I found that the user-defined login page user name and password of the school were all transmitted in plain text. I was overjoyed to use HttpClient to simulate login, but it always showed a 400 error. Reference to many information from CSDN and blog garden is still unsolvable. Finally, I can only push to From the beginning, I finally found the damn 5 GETs to get the wonderful setting of the real cookies (the name criticizes the spinning university education system, the username and password plaintext storage is actually so complicated to log in)

Without further ado, start with a step-by-step ultra-detailed analysis of the crawling educational system


analysis

Open the login page of the school's administrative system, and first request to generate a cookie for POST use

Manual login, you can see that there are 5 302 status requests, of which POST is to send login data, you can see that username and password are username, password, execution and rmshown are the marks of the number of visits, no matter what , But there is a lt. After searching, it is found that lt is an embedded field of the login page, which can be obtained directly from the login page and analyze each request separately;

The first POST uses cookies from the login page to get iPlanetDirectoryPro, and the redirected

Location

http://jwglxt.wtu.edu.cn/sso/j…dPM5vmJu1586512656377-w6Ia-cas

The second 302 is GET, you can see that iPlanetDirectoryPro can come to JSESSIONID and the URI of the next GET

Location

http://jwglxt.wtu.edu.cn/sso/j…1882D5B308262624B9BF5D5181B1D0

It should be noted that this URI and cookies are not final, JSESSIONID is only the middle cookie used to verify other GET

You can see in a GET using the cookies just got, get a redirect page

Location

http://jwglxt.wtu.edu.cn/ticke…2928F9906338285585624192011C17

Obviously, this is the address of the next GET

GET the URI obtained in the previous step, and finally got the final cookie, but at the same time there is a Location, you may want to jump to the home page directly, but no, you still need to get it, so that you can get the dynamic post-login page, Because the information such as the schedule and the like all need the source address of the homepage, it is not allowed to jump directly, otherwise a 400 error will be reported;

Location

/xtgl/login_slogin.html

Note that this is a relative path and needs to be prefixed with http://jwglxt.wtu.edu.cn

Use the final iPlanetDirectoryPro and JSESSIONID to continue to GET the last obtained path, and finally get the final page address

(It is also a relative address)

Using the final URI and Cookies request, I finally got the page after login

Open the timetable to test, get the timetable, indicating success

Check the request and find that it is POST, the final URI and Cookies are used

The above login principles are all analyzed, and the actual operation of the code begins

 

Code

The first GET

Use GET to parse the login page to get the initial cookies and LT

GetMethod getMethod = new GetMethod(url);
        //发送get
        httpClient.executeMethod(getMethod);
        //获取get的内容
        InputStream inputStream = getMethod.getResponseBodyAsStream();
        StringBuilder output = new StringBuilder();
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
        BufferedReader reader = new BufferedReader(inputStreamReader);
        String line = reader.readLine();
        while (line != null) {
            output.append(line);
            line = reader.readLine();
        }
        //解析为文档树
        Document document = Jsoup.parseBodyFragment(output.toString());
        Element body = document.body();
        //找到lt
        lt = body.select("[name=lt]").attr("value");
        System.out.println("lt: " + lt);
        //释放链接
        getMethod.releaseConnection();
        //状态码
        int statusCodeGet1 = getMethod.getStatusCode();
        System.out.println("Status code get1 :" + statusCodeGet1);
        //得到Cookies
        JSESSION = getMethod.getResponseHeader("Set-Cookie").getValue().trim().split(";")[0].split(",")[1].trim().split("=")[1];
        System.out.println("Cookies GET1 Jsession:" + JSESSION);
        ROUTE = getMethod.getResponseHeader("Set-Cookie").getValue().trim().split(";")[0].split(",")[0].trim().split("=")[1];
        System.out.println("Cookies GET1 Route:" + ROUTE);

POST login

Transmit login information and get 1/2 cookies and a URI

String geturi2 = null;
        String loURI = "https://auth.wtu.edu.cn/authserver/login;jsessionid=";
        loURI += JSESSION;
        loURI += "?service=http%3A%2F%2Fjwglxt.wtu.edu.cn%2Fsso%2Fjziotlogin";
 PostMethod postMethod = new PostMethod(murl);
            //请求头
            postMethod.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
            postMethod.setRequestHeader("Accept-Encoding", "gzip, deflate, br");
            postMethod.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
            postMethod.setRequestHeader("Connection", "keep-alive");
            postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            postMethod.setRequestHeader("Cookie", "route=" + ROUTE + "; JSESSIONID_auth=" + JSESSION);
            postMethod.setRequestHeader("Host", "auth.wtu.edu.cn");
            postMethod.setRequestHeader("Origin", "https://auth.wtu.edu.cn");
            postMethod.setRequestHeader("Referer", url);
            postMethod.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0");
            //参数
            postMethod.addParameter(new NameValuePair("username", usernam));
            postMethod.addParameter(new NameValuePair("password", password));
            postMethod.addParameter(new NameValuePair("lt", lt));
            postMethod.addParameter(new NameValuePair("dllt", "userNamePasswordLogin"));
            postMethod.addParameter(new NameValuePair("execution", "e1s1"));
            postMethod.addParameter(new NameValuePair("_eventId", "submit"));
            postMethod.addParameter(new NameValuePair("rmShown", "1"));
            mClient.executeMethod(postMethod);
 //状态码
        int statusCodePost = postMethod.getStatusCode();
        System.out.println("Status code post :" + statusCodePost);
        //拿到第二步Get网址
        geturi2 = postMethod.getResponseHeader("Location").toString().split(" ")[1];
        System.out.println("Get Uri 2:" + geturi2);
        //拿到iPlanetDirectoryPro
        Header[] headers = postMethod.getResponseHeaders("Set-Cookie");
        iPlanetDirectoryPro = headers[2].getValue().split(";")[0];
        System.out.println("iPlanetDirectoryPro: " + iPlanetDirectoryPro);

The second Get

Get intermediate cookies and a small step URI

String geturi3 = null;
        String JSESSIONID2 = null;
        //第二次GET请求进入登录界面,拿到第二个JSESSIONID_iPlanetDirectoryPro
        GetMethod getMethod2 = new GetMethod(geturi2);
        getMethod2.addRequestHeader(new Header("Cookie", iPlanetDirectoryPro));
        getMethod2.setFollowRedirects(false);//不自动处理重定向
        int statusCodeGet2 = httpClient.executeMethod(getMethod2);//状态码
        System.out.println("Status code get2 :" + statusCodeGet2);
        //得到重定向网址
        geturi3 = getMethod2.getResponseHeader("Location").toString();
        geturi3 = geturi3.replaceAll(" ", "");//去掉空格
        geturi3 = geturi3.split(":", 2)[1];//得到网址
        System.out.println("Get Uri 3 :" + geturi3);
        //得到set-Cookie 拿到JSESSIONID2
        Header[] headers2 = getMethod2.getResponseHeaders("Set-Cookie");
        JSESSIONID2 = headers2[0].getValue().split(";")[0];
        System.out.println("JSESSIONID2: " + JSESSIONID2);

The third GET

Get the URI address of the final cookies

 String geturi4 = null;
        GetMethod getMethod3 = new GetMethod(geturi3);
        getMethod3.setFollowRedirects(false);
        getMethod3.addRequestHeader(new Header("Cookie", JSESSIONID2));
        int statusCodeGet3 = httpClient.executeMethod(getMethod3);
        System.out.println("Status code get3:" + statusCodeGet3);
        //获取下一步URI
        geturi4 = getMethod3.getResponseHeader("Location").toString();
        geturi4 = geturi4.replaceAll(" ", "");//去掉空格
        geturi4 = geturi4.split(":", 2)[1];//得到网址
        System.out.println("Get Uri 4:" + geturi4);

Fourth GET

Get final cookies and next URI

String geturi5 = "http://jwglxt.wtu.edu.cn";
        GetMethod getMethod4 = new GetMethod(geturi4);
        getMethod4.setFollowRedirects(false);
        getMethod4.addRequestHeader(new Header("Cookie", iPlanetDirectoryPro));
        //状态和执行
        int statusCodeGet4 = httpClient.executeMethod(getMethod4);
        System.out.println("Status code get4:" + statusCodeGet4);
        //获取下一步URI
        String get4xd;//设置临时变量,相对URI
        get4xd = getMethod4.getResponseHeader("Location").toString();
        get4xd = get4xd.replaceAll(" ", "");//去掉空格
        get4xd = get4xd.split(":", 2)[1];//得到网址
        //拼接真实URI
        geturi5 += get4xd;
        System.out.println("Get Uri 5:" + geturi5);
        //得到set-Cookie 拿到真实
        Header[] headers3 = getMethod2.getResponseHeaders("Set-Cookie");
        JSESSION = headers3[0].getValue().split(";")[0];
        System.out.println("JSESSIONID: " + JSESSION);

The fifth GET

Get the page after login

  GetMethod getMethod5 = new GetMethod(geturi5);
        getMethod5.setFollowRedirects(false);
        //设置Cookie
        getMethod5.addRequestHeader(new Header("Cookie", iPlanetDirectoryPro + ";" + JSESSION));
        //状态和执行
        int statusCodeGet5 = httpClient.executeMethod(getMethod5);
        System.out.println("Status code get5:" + statusCodeGet5);
        //获取下一步URI
        String get5xd;//设置临时变量,相对URI
        get5xd = getMethod5.getResponseHeader("Location").toString();
        get5xd = get5xd.replaceAll(" ", "");//去掉空格
        get5xd = get5xd.split(":", 2)[1];//得到网址
        //拼接真实URI
        loginuri += get5xd;
        System.out.println("Loginuri :" + loginuri);

 

test

I have obtained all the cookies and the final URI before, and now I can grab the educational administration system and it is unobstructed. Then first test the homepage after login

GetMethod getMethodLog = new GetMethod(loginuri);
        getMethodLog.addRequestHeader(new Header("Cookie", iPlanetDirectoryPro + ";" + JSESSION));
        //状态和执行
        int statusCodelog = httpClient.executeMethod(getMethodLog);
        System.out.println("Status code log:" + statusCodelog);
        String result = getMethodLog.getResponseBodyAsString();
        System.out.println("最终结果:\n"+result);

Test crawling schedule information, you can know from the previous analysis, this is a POST

 String kcb = "http://jwglxt.wtu.edu.cn/kbcx/xskbcx_cxXsKb.html?gnmkdm=N253508";
PostMethod postMethod = new PostMethod(tourl);
            //请求头
            postMethod.setRequestHeader("Accept", "*/*");
            postMethod.setRequestHeader("Accept-Encoding", "gzip, deflate, br");
            postMethod.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
            postMethod.setRequestHeader("Connection", "keep-alive");
            postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            postMethod.setRequestHeader("Cookie", Cookies);
            postMethod.setRequestHeader("Host", "auth.wtu.edu.cn");
            postMethod.setRequestHeader("Origin", "https://auth.wtu.edu.cn");
            postMethod.setRequestHeader("Referer", "http://jwglxt.wtu.edu.cn/kbcx/xskbcx_cxXskbcxIndex.html?gnmkdm=N253508&layout=default&su=" + usernam);
            postMethod.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0");
            postMethod.setRequestHeader("X-Requested-With", "XMLHttpRequest");
            //表单数据
            postMethod.addParameter("xnm", "2019");
            postMethod.addParameter("xqm", "12");
            postMethod.setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");

            mClient.executeMethod(postMethod);
 int kcbcode = postMethodkcb.getStatusCode();
        System.out.println("Status code kcb :" + kcbcode);
        String ss=new String(postMethodkcb.getResponseBody(), Charset.forName("ASCII"));
        System.out.println(ss);

        //读取json
        InputStream in = postMethodkcb.getResponseBodyAsStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(in,"ISO-8859-1"));
        String tempbf;
        StringBuffer html = new StringBuffer(8*1024);
        while ((tempbf = br.readLine()) != null) {
            html.append(tempbf +"\n");
        }
        System.out.println(html);

 

Let's take a look at the results:-

OK, you can see that the data has all come out, then just get the useful data and search it directly on the page just like the previous LT grab. Everything is done,

 

Complete code

Finally, because POST is too long and looks unsightly, two POSTs are encapsulated into an internal class. The complete code is as follows. You can try to crawl your school's educational system!

Note: Requires two toolkits of httpclient and Jsoup, you can add Maven dependency or self-download

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

public class WTU2 {


    private static String usernam = "username";
    private static String password = "password";
    private static String lt = "";
    private static String JSESSION = "";
    private static String ROUTE = "";
    private static String iPlanetDirectoryPro = null;
    private static String loginuri = "http://jwglxt.wtu.edu.cn";
    private static String url = "https://auth.wtu.edu.cn/authserver/login?service=http%3A%2F%2Fjwglxt.wtu.edu.cn%2Fsso%2Fjziotlogin";

    public static void main(String[] ars) throws Exception {
        //定义一个Httpclient对象(相当于浏览器)
        HttpClient httpClient = new HttpClient();


        /*
         * 第一步:第一次Get,获取Cookie和lt
         * */
        //实例化一个get方法
        System.out.println("\n——————————————————————第一次GET——————————————————");
        GetMethod getMethod = new GetMethod(url);
        //发送get
        httpClient.executeMethod(getMethod);
        //获取get的内容
        InputStream inputStream = getMethod.getResponseBodyAsStream();
        StringBuilder output = new StringBuilder();
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
        BufferedReader reader = new BufferedReader(inputStreamReader);
        String line = reader.readLine();
        while (line != null) {
            output.append(line);
            line = reader.readLine();
        }
        //解析为文档树
        Document document = Jsoup.parseBodyFragment(output.toString());
        Element body = document.body();
        //找到lt
        lt = body.select("[name=lt]").attr("value");
        System.out.println("lt: " + lt);
        //释放链接
        getMethod.releaseConnection();
        //状态码
        int statusCodeGet1 = getMethod.getStatusCode();
        System.out.println("Status code get1 :" + statusCodeGet1);
        //得到Cookies
        JSESSION = getMethod.getResponseHeader("Set-Cookie").getValue().trim().split(";")[0].split(",")[1].trim().split("=")[1];
        System.out.println("Cookies GET1 Jsession:" + JSESSION);
        ROUTE = getMethod.getResponseHeader("Set-Cookie").getValue().trim().split(";")[0].split(",")[0].trim().split("=")[1];
        System.out.println("Cookies GET1 Route:" + ROUTE);


        /*
         * 第二步:POST 获取Location和iPlanetDirectoryPro并且发送登录数据
         * */
        System.out.println("\n——————————————————————POST——————————————————");
        //拼接LoginURI
        String geturi2 = null;
        String loURI = "https://auth.wtu.edu.cn/authserver/login;jsessionid=";
        loURI += JSESSION;
        loURI += "?service=http%3A%2F%2Fjwglxt.wtu.edu.cn%2Fsso%2Fjziotlogin";
        //POST请求发送登录数据
        PostMethod postMethod = new Urlt().postAction(httpClient, loURI);
        //状态码
        int statusCodePost = postMethod.getStatusCode();
        System.out.println("Status code post :" + statusCodePost);
        //拿到第二步Get网址
        geturi2 = postMethod.getResponseHeader("Location").toString().split(" ")[1];
        System.out.println("Get Uri 2:" + geturi2);
        //拿到iPlanetDirectoryPro
        Header[] headers = postMethod.getResponseHeaders("Set-Cookie");
        iPlanetDirectoryPro = headers[2].getValue().split(";")[0];
        System.out.println("iPlanetDirectoryPro: " + iPlanetDirectoryPro);


        /*
         * 第三步:第二次GET,获取下一步的uri和中间cooki
         * */
        System.out.println("\n——————————————————————第二次GET——————————————————");
        String geturi3 = null;
        String JSESSIONID2 = null;
        //第二次GET请求进入登录界面,拿到第二个JSESSIONID_iPlanetDirectoryPro
        GetMethod getMethod2 = new GetMethod(geturi2);
        getMethod2.addRequestHeader(new Header("Cookie", iPlanetDirectoryPro));
        getMethod2.setFollowRedirects(false);//不自动处理重定向
        int statusCodeGet2 = httpClient.executeMethod(getMethod2);//状态码
        System.out.println("Status code get2 :" + statusCodeGet2);
        //得到重定向网址
        geturi3 = getMethod2.getResponseHeader("Location").toString();
        geturi3 = geturi3.replaceAll(" ", "");//去掉空格
        geturi3 = geturi3.split(":", 2)[1];//得到网址
        System.out.println("Get Uri 3 :" + geturi3);
        //得到set-Cookie 拿到JSESSIONID2
        Header[] headers2 = getMethod2.getResponseHeaders("Set-Cookie");
        JSESSIONID2 = headers2[0].getValue().split(";")[0];
        System.out.println("JSESSIONID2: " + JSESSIONID2);


        /*
         * 第四步 第三次GET 获取下一步uri
         * */
        System.out.println("\n——————————————————————第三次GET——————————————————");
        String geturi4 = null;
        GetMethod getMethod3 = new GetMethod(geturi3);
        getMethod3.setFollowRedirects(false);
        getMethod3.addRequestHeader(new Header("Cookie", JSESSIONID2));
        int statusCodeGet3 = httpClient.executeMethod(getMethod3);
        System.out.println("Status code get3:" + statusCodeGet3);
        //获取下一步URI
        geturi4 = getMethod3.getResponseHeader("Location").toString();
        geturi4 = geturi4.replaceAll(" ", "");//去掉空格
        geturi4 = geturi4.split(":", 2)[1];//得到网址
        System.out.println("Get Uri 4:" + geturi4);


        /*
         * 第五步 第四次GET 获取下一步uri和真实的Cookie
         * */
        System.out.println("\n——————————————————————第四次GET——————————————————");
        String geturi5 = "http://jwglxt.wtu.edu.cn";
        GetMethod getMethod4 = new GetMethod(geturi4);
        getMethod4.setFollowRedirects(false);
        getMethod4.addRequestHeader(new Header("Cookie", iPlanetDirectoryPro));
        //状态和执行
        int statusCodeGet4 = httpClient.executeMethod(getMethod4);
        System.out.println("Status code get4:" + statusCodeGet4);
        //获取下一步URI
        String get4xd;//设置临时变量,相对URI
        get4xd = getMethod4.getResponseHeader("Location").toString();
        get4xd = get4xd.replaceAll(" ", "");//去掉空格
        get4xd = get4xd.split(":", 2)[1];//得到网址
        //拼接真实URI
        geturi5 += get4xd;
        System.out.println("Get Uri 5:" + geturi5);
        //得到set-Cookie 拿到真实
        Header[] headers3 = getMethod2.getResponseHeaders("Set-Cookie");
        JSESSION = headers3[0].getValue().split(";")[0];
        System.out.println("JSESSIONID: " + JSESSION);


        /*
         * 第六部 第五次GET 获取最终的登录页面
         * */
        System.out.println("\n——————————————————————第五次GET——————————————————");
        GetMethod getMethod5 = new GetMethod(geturi5);
        getMethod5.setFollowRedirects(false);
        //设置Cookie
        getMethod5.addRequestHeader(new Header("Cookie", iPlanetDirectoryPro + ";" + JSESSION));
        //状态和执行
        int statusCodeGet5 = httpClient.executeMethod(getMethod5);
        System.out.println("Status code get5:" + statusCodeGet5);
        //获取下一步URI
        String get5xd;//设置临时变量,相对URI
        get5xd = getMethod5.getResponseHeader("Location").toString();
        get5xd = get5xd.replaceAll(" ", "");//去掉空格
        get5xd = get5xd.split(":", 2)[1];//得到网址
        //拼接真实URI
        loginuri += get5xd;
        System.out.println("Loginuri :" + loginuri);


        /*
         * 第七部 第六次GET 登录教务系统
         * */
        System.out.println("\n——————————————————————登录页面——————————————————");
        GetMethod getMethodLog = new GetMethod(loginuri);
        getMethodLog.addRequestHeader(new Header("Cookie", iPlanetDirectoryPro + ";" + JSESSION));
        //状态和执行
        int statusCodelog = httpClient.executeMethod(getMethodLog);
        System.out.println("Status code log:" + statusCodelog);
//        String result = getMethodLog.getResponseBodyAsString();
//        System.out.println("最终结果:\n"+result);



        /*
         * 学籍信息测试
         * */
        System.out.println("\n——————————————————————学籍页面——————————————————");
        String lf="http://jwglxt.wtu.edu.cn/xsxxxggl/xsgrxxwh_cxXsgrxx.html?gnmkdm=N100801&layout=default&su="+usernam;
        GetMethod getMethodtest = new GetMethod(lf);
        getMethodtest.addRequestHeader(new Header("Cookie", iPlanetDirectoryPro + ";" + JSESSION));
        //状态和执行
        int statusCodetest = httpClient.executeMethod(getMethodtest);
        System.out.println("Status code test1" + statusCodetest);
        String resulttest = getMethodtest.getResponseBodyAsString();
        System.out.println(resulttest);


        /*
         * Test 获取课表
         * */
        System.out.println("\n——————————————————————课表——————————————————");
        String kcb = "http://jwglxt.wtu.edu.cn/kbcx/xskbcx_cxXsKb.html?gnmkdm=N253508";
        PostMethod postMethodkcb = new Urlt().postKCB(httpClient, kcb, loginuri, iPlanetDirectoryPro + ";" + JSESSION);
        int kcbcode = postMethodkcb.getStatusCode();
        System.out.println("Status code kcb :" + kcbcode);
        String ss=new String(postMethodkcb.getResponseBody(), Charset.forName("ASCII"));
        System.out.println(ss);

        //读取json
        InputStream in = postMethodkcb.getResponseBodyAsStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(in,"ISO-8859-1"));
        String tempbf;
        StringBuffer html = new StringBuffer(8*1024);
        while ((tempbf = br.readLine()) != null) {
            html.append(tempbf +"\n");
        }
        System.out.println(html);
    }

    static class Urlt {

        //登录
        public PostMethod postAction(HttpClient client, String murl) throws IOException {
            HttpClient mClient = client;
            PostMethod postMethod = new PostMethod(murl);
            //请求头
            postMethod.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
            postMethod.setRequestHeader("Accept-Encoding", "gzip, deflate, br");
            postMethod.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
            postMethod.setRequestHeader("Connection", "keep-alive");
            postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            postMethod.setRequestHeader("Cookie", "route=" + ROUTE + "; JSESSIONID_auth=" + JSESSION);
            postMethod.setRequestHeader("Host", "auth.wtu.edu.cn");
            postMethod.setRequestHeader("Origin", "https://auth.wtu.edu.cn");
            postMethod.setRequestHeader("Referer", url);
            postMethod.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0");
            //参数
            postMethod.addParameter(new NameValuePair("username", usernam));
            postMethod.addParameter(new NameValuePair("password", password));
            postMethod.addParameter(new NameValuePair("lt", lt));
            postMethod.addParameter(new NameValuePair("dllt", "userNamePasswordLogin"));
            postMethod.addParameter(new NameValuePair("execution", "e1s1"));
            postMethod.addParameter(new NameValuePair("_eventId", "submit"));
            postMethod.addParameter(new NameValuePair("rmShown", "1"));
            mClient.executeMethod(postMethod);
            return postMethod;
        }

        //请求课表
        public PostMethod postKCB(HttpClient client, String tourl, String refurl, String Cookies) throws IOException {
            HttpClient mClient = client;
            PostMethod postMethod = new PostMethod(tourl);
            //请求头
            postMethod.setRequestHeader("Accept", "*/*");
            postMethod.setRequestHeader("Accept-Encoding", "gzip, deflate, br");
            postMethod.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
            postMethod.setRequestHeader("Connection", "keep-alive");
            postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            postMethod.setRequestHeader("Cookie", Cookies);
            postMethod.setRequestHeader("Host", "auth.wtu.edu.cn");
            postMethod.setRequestHeader("Origin", "https://auth.wtu.edu.cn");
            postMethod.setRequestHeader("Referer", "http://jwglxt.wtu.edu.cn/kbcx/xskbcx_cxXskbcxIndex.html?gnmkdm=N253508&layout=default&su=" + usernam);
            postMethod.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0");
            postMethod.setRequestHeader("X-Requested-With", "XMLHttpRequest");
            //表单数据
            postMethod.addParameter("xnm", "2019");
            postMethod.addParameter("xqm", "12");
            postMethod.setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8");

            mClient.executeMethod(postMethod);
            return postMethod;
        }
    }
}

If it's useful, remember to like it, you can discuss and make progress together!

Please indicate the source!

Published 6 original articles · praised 7 · visits 254

Guess you like

Origin blog.csdn.net/XiaoYunKuaiFei/article/details/105438789