JAVA——基于HttpClient的全国大学英语四、六级考试(CET4&CET6)[2019年下半年]查询DEMO

基本概念

HttpComponents(HttpClient)

超文本传输​​协议(HTTP)可能是当今Internet上使用的最重要的协议。Web服务,支持网络的设备和网络计算的增长继续将HTTP协议的作用扩展到用户驱动的Web浏览器之外,同时增加了需要HTTP支持的应用程序的数量。

HttpComponents是为扩展而设计的,同时提供了对基本HTTP协议的强大支持,对于构建HTTP感知的客户端和服务器应用程序(例如Web浏览器,Web Spider,HTTP代理,Web服务传输库或利用或扩展HTTP协议以进行分布式通信。

问题分析

全国大学英语四、六级考试(含口语)成绩查询官网: 

http://cet.neea.edu.cn/cet

 考试代码数据文件:

 API:

POST请求

URL:http://cache.neea.edu.cn/cet/query

参数:

扫描二维码关注公众号,回复: 9419186 查看本文章

        data:考试代码,准考证考,考生姓名

源代码

JAVA版本 

: HttpClientUtils为HttpClient工具类,参考:https://shentuzhigang.blog.csdn.net/article/details/104274609

(无验证码识别) 

package club.zstuca.myzstu.service.Impl;

import club.zstuca.myzstu.httpclient.HttpClientUtils;
import club.zstuca.myzstu.service.ICETService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author ShenTuZhiGang
 * @Version 1.0.0
 * @Date 2020-02-21 11:31
 */

@Service
public class CETServiceImpl implements ICETService {
    private static final String QUERY_URL = "http://cache.neea.edu.cn/cet/query";
    @Override
    public String query(String zkzh, String name){
        Map<String,String> headers=new HashMap<>();
        headers.put("Referer","http://cet.neea.edu.cn/cet/query.html");
        Map<String,String> params=new HashMap<>();
        char idx = zkzh.charAt(9);
        String z = null;
        if(idx == '1'){
            z = "CET4_192_DANGCI";
        }else if(idx == '2'){
            z = "CET6_192_DANGCI";
        }
        String data = z + "," + zkzh + "," + name;
        params.put("data",data);
        String res = HttpClientUtils.doGetRequest(QUERY_URL,headers,params);
        Pattern pattern = Pattern.compile("result.callback\\((.*)\\);");
        Matcher m = pattern.matcher(res);
        String obj = "";
        if (m.find()) {
            obj = m.group(1);
        }
        return obj;
    }
}

Python版本

https://blog.csdn.net/ZZPHOENIX/article/details/81952224

参考文章

https://blog.csdn.net/ZZPHOENIX/article/details/81952224

https://www.cnblogs.com/w1570631036/p/5187101.html

发布了1408 篇原创文章 · 获赞 251 · 访问量 38万+

猜你喜欢

转载自blog.csdn.net/weixin_43272781/article/details/104515663
今日推荐