zoukankan      html  css  js  c++  java
  • 自动审核工具

    本脚本依赖 jodd http工具箱,流程为登录、查询、解析、审核

    package jodd.http;
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.StringReader;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    public class AutoApply {
    
        String username = "";
        String password = "";
    
        String machineInfo = "2YOcO6I0x6XXGNfPd5SxS30E%2F26nW7Wd%2FJCZo5%2F0guOo7cjy0DiJVgTio2eNwb0QVroN2sKIzjhumjgQpkLBoghi6zjes2WiEt2D9YhqiZYGWyFRrQOdXUi58SjU9GSapcOUjBSZK61NGkYd0zRdte9fAZbRl3FuU0k22JyrI9APQ%2FbD1RKfKkh4mocLlZD6IAgQBv0k9syWQz%2B60AYwZaQccgFItPuL";
    
        String loginUrl = "http://172.18.138.35:8888/sign/login/login.do?";
    
        String jsessionid = "";
    
        public static void main(String[] args) throws IOException {
    
            new AutoApply().process();
    
        }
    
        public void process() throws IOException {
    
            login();
    
            List<String> list = getIds();
    
            while (list != null && list.size() > 0) {
    
                apply(list);
    
                list = getIds();
            }
    
        }
    
        private void login() throws IOException {
    
            String url = loginUrl + "username=" + username + "&password=" + password + "&machineInfo" + machineInfo;
    
            String body = HttpRequest.post(url).send().toString();
    
            BufferedReader reader = new BufferedReader(new StringReader(body));
    
            String line = reader.readLine();
            while (line != null) {
                if (line.contains("Set-Cookie")) {
                    jsessionid = line.substring(line.indexOf("JSESSIONID="), line.indexOf("; Path")).replace("JSESSIONID=", "");
                    break;
                }
    
                line = reader.readLine();
            }
    
        }
    
        public List<String> getIds() throws IOException {
    
            Map<String, String> para = new HashMap<String, String>();
            para.put("pageNo", "1");
            para.put("query_beginDate", "20121101");
            para.put("query_endDate", "20131206");
            para.put("role", "2");
            para.put("userId", "209");
            para.put("query_chekSt", "01");
    
            String body = HttpRequest.get("http://172.18.138.35:8888/sign/workReport/workReport!list.do").query(para).header("Cookie",
                    "JSESSIONID=" + jsessionid).send().bodyText();
    
            BufferedReader reader = new BufferedReader(new StringReader(body));
    
            List<String> list = new ArrayList<String>();
            String line = reader.readLine();
            while (line != null) {
                if (line.contains("通过审核") && line.contains("/sign/workReport/workReport!checkReport.do")) {
                    String id = line.substring(line.indexOf("workId="), line.indexOf("&workStatus")).replace("workId=", "");
    
                    list.add(id);
                }
    
                line = reader.readLine();
            }
            return list;
        }
    
        public void apply(List<String> list) {
    
            for (String id : list) {
                Map<String, String> para = new HashMap<String, String>();
                para.put("workId", id);
                para.put("workStatus", "02");
                HttpRequest.get("http://172.18.138.35:8888/sign/workReport/workReport!checkReport.do").query(para).header("Cookie",
                        "JSESSIONID=" + jsessionid).send();
    
                System.out.println(id + " success");
    
            }
    
        }
    
    }
  • 相关阅读:
    什么是HTTP
    通过递归法解决阶梯问题(n个台阶,上楼可以一步上1阶,也可以一步上2阶,一共有多少种上楼的方法)
    在Intelli Idea中使用plantuml(plantuml时序图的使用)
    Java中if(boolean)与if(boolean=true)的区别
    实现一个Servlet程序
    退出mysql的编辑模式
    mysql数据库基本操作命令行
    通过mysql命令查看mysql服务实例支持的搜索引擎
    Mac环境下使用终端启动Mysql,并进行mysql数据库的连接
    路飞学城Python-Day4
  • 原文地址:https://www.cnblogs.com/benx/p/3461989.html
Copyright © 2011-2022 走看看