上下班自动打卡系统
??某程序員上下班要用本人的IP地址在公司考勤系統在線打卡各一次。
??假設公司的打卡流程為登錄-提交表單-填寫工時(下班),登錄后考勤頁面表單包含個人姓名,工號,IP地址,隨機驗證碼,時間戳等信息,提交表單后服務端首先檢查IP地址是否與員工登記的IP地址一致,隨后驗證時間是否在正常的上下班時間段,返回考勤正常或異常。
??編程語言:JAVA
??直接上源碼。
上班打卡
package htmlparse;import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Random;import org.jsoup.Connection; import org.jsoup.Connection.Response; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements;public class InCheck {public static void main(String[] arg0) throws IOException{// HttpURLConnection httpConn=null; // BufferedReader in=null; // PrintWriter out=null; // try { // URL url=new URL("http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default"); // httpConn=(HttpURLConnection)url.openConnection(); // httpConn.setRequestMethod("POST"); // httpConn.setDoInput(true); // httpConn.setDoOutput(true); // httpConn.setInstanceFollowRedirects(false); // // httpConn.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); // httpConn.setRequestProperty("Accept-Encoding", "gzip, deflate"); // httpConn.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8"); // httpConn.setRequestProperty("Cache-Control", "max-age=0"); // httpConn.setRequestProperty("Connection", "keep-alive"); // httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); // httpConn.setRequestProperty("Cookie", "ff_username=os.*******=ff_username; JSESSIONID=ID669715155DB0.22358644074085698End; sapj2ee_*=669715155"); // httpConn.setRequestProperty("Host", "eis.ffcs.cn"); // httpConn.setRequestProperty("Origin", "http://eis.ffcs.cn"); // httpConn.setRequestProperty("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default"); // httpConn.setRequestProperty("Upgrade-Insecure-Requests", "1"); // httpConn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36"); // // //發送post請求參數 // out=new PrintWriter(httpConn.getOutputStream()); // out.println("login_submit=on&login_do_redirect=1&no_cert_storing=on&j_user=os.*******&j_password=??????&j_authscheme=default"); // out.flush(); // // Map<String, List<String>> map = httpConn.getHeaderFields(); // // 遍歷所有的響應頭字段 // for (String key : map.keySet()) { // System.out.println(key + "--->" + map.get(key)); // } // // //讀取響應 // if(httpConn.getResponseCode()==302){ // StringBuffer content=new StringBuffer(); // String tempStr=""; // in=new BufferedReader(new InputStreamReader(httpConn.getInputStream())); // while((tempStr=in.readLine())!=null){ // content.append(tempStr); // } // System.out.println(new String(content.toString().getBytes(),Charset.forName("utf-8"))); // } // } catch (IOException e) { // e.printStackTrace(); // }finally{ // try{ // in.close(); // out.close(); // httpConn.disconnect(); // }catch(Exception e){ // e.printStackTrace(); // } // }try {Map<String, String> cookies = null;String sapj2ee_star = null;String JSESSIONID = null;String ASPdotNET_SessionId = null;String MYSAPSSO2 = null;System.out.println(1);String url = "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default";Connection conn = Jsoup.connect(url);conn.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn.header("Accept-Encoding", "gzip, deflate, sdch");conn.header("Accept-Language", "zh-CN,zh;q=0.8");conn.header("Connection", "keep-alive");conn.header("Cookie", "ff_username=os.*******=ff_username");//conn.header("Cookie", "ff_username=os.*******=ff_username; JSESSIONID=ID669715155DB0.22358644074085698End; sapj2ee_*=669715155");conn.header("Host", "eis.ffcs.cn");conn.header("Upgrade-Insecure-Requests", "1");conn.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn.method(Connection.Method.GET); // conn.followRedirects(false);Response response = conn.timeout(10000).execute();System.out.println(response.statusCode()); // System.out.println(response.body());System.out.println(response.headers());cookies = response.cookies();sapj2ee_star = cookies.get("sapj2ee_*");JSESSIONID = cookies.get("JSESSIONID");System.out.println(cookies); //sapj2ee_*=669715155; Version=1; Path=/ //JSESSIONID=ID669715155DB0.24023707681679896End; Version=1; Domain=.ffcs.cn; Path=/System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);System.out.println(2);String url2 = "http://bem.ffcs.cn:81/mis/eislogin.aspx";Connection conn2 = Jsoup.connect(url2);conn2.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn2.header("Accept-Encoding", "gzip, deflate, sdch");conn2.header("Accept-Language", "zh-CN,zh;q=0.8");conn2.header("Connection", "keep-alive"); // conn2.header("Cookie", "ASP.NET_SessionId=1gjx3p23rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn2.header("Host", "bem.ffcs.cn:81");conn2.header("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default");conn2.header("Upgrade-Insecure-Requests", "1");conn2.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn2.cookie("JSESSIONID","ID669715155DB0.4105357846396225End");conn2.method(Connection.Method.GET);Response response2 = conn2.timeout(10000).execute();System.out.println(response2.statusCode()); // System.out.println(response2.body());System.out.println(response2.headers());cookies = response2.cookies();ASPdotNET_SessionId = cookies.get("ASP.NET_SessionId");System.out.println(cookies);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);System.out.println(3);String url3 = "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default";Connection conn3 = Jsoup.connect(url3);conn3.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn3.header("Accept-Encoding", "gzip, deflate");conn3.header("Accept-Language", "zh-CN,zh;q=0.8");conn3.header("Cache-Control","max-age=0");//conn3.header("Connection", "keep-alive"); // conn3.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn3.header("Content-Length","111");conn3.header("Content-Type","application/x-www-form-urlencoded");conn3.header("Host", "eis.ffcs.cn");conn3.header("Origin","http://eis.ffcs.cn");conn3.header("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default");conn3.header("Upgrade-Insecure-Requests", "1");conn3.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn3.cookie("ff_username","os.*******=ff_username");conn3.cookie("sapj2ee_*", sapj2ee_star);conn3.cookie("JSESSIONID", JSESSIONID);conn3.data("login_submit", "on");conn3.data("login_do_redirect", "1");conn3.data("no_cert_storing", "on");conn3.data("j_user", "os.*******");conn3.data("j_password", "??????");conn3.data("j_authscheme", "default");conn3.method(Connection.Method.POST);conn3.followRedirects(false);Response response3 = conn3.timeout(10000).execute();System.out.println(response3.statusCode()); // System.out.println(response3.body());System.out.println(response3.headers());cookies = response3.cookies();String redirectUrl = response3.header("Location");//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndMYSAPSSO2 = cookies.get("MYSAPSSO2");System.out.println(cookies);System.out.println(MYSAPSSO2);System.out.println(redirectUrl);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);System.out.println(4);//String url4 = "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default";String url4 = redirectUrl;Connection conn4 = Jsoup.connect(url4);conn4.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn4.header("Accept-Encoding", "gzip, deflate, sdch");conn4.header("Accept-Language", "zh-CN,zh;q=0.8");conn4.header("Cache-Control","max-age=0");//conn4.header("Connection", "keep-alive"); // conn4.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn4.header("Content-Length","111");conn4.header("Host", "eis.ffcs.cn");conn4.header("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default");conn4.header("Upgrade-Insecure-Requests", "1");conn4.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn4.cookie("ff_username","os.*******=ff_username");conn4.cookie("sapj2ee_*", sapj2ee_star);conn4.cookie("JSESSIONID", JSESSIONID);conn4.cookie("MYSAPSSO2", MYSAPSSO2);conn4.method(Connection.Method.GET);System.out.println(5);Response response4 = conn4.timeout(10000).execute();System.out.println(response4.statusCode()); // System.out.println(response4.body());System.out.println(response4.headers());cookies = response4.cookies();sapj2ee_star=cookies.get("sapj2ee_*");//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);///// System.out.println("4_5");String url4_5 = "http://eis.ffcs.cn/irj/portalapps/com.sap.portal.htmlb/jslib/emptyhover.html";Connection conn4_5 = Jsoup.connect(url4_5);conn4_5.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn4_5.header("Accept-Encoding", "gzip, deflate, sdch");conn4_5.header("Accept-Language", "zh-CN,zh;q=0.8");conn4_5.header("Connection", "keep-alive"); // conn4_5.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn4_5.header("Host", "eis.ffcs.cn");conn4_5.header("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default");conn4_5.header("Upgrade-Insecure-Requests", "1");conn4_5.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn4_5.cookie("JSESSIONID", JSESSIONID);conn4_5.cookie("sapj2ee_*", sapj2ee_star);conn4_5.cookie("MYSAPSSO2", MYSAPSSO2);conn4_5.method(Connection.Method.GET);Response response4_5 = conn4_5.timeout(10000).execute();System.out.println(response4_5.statusCode());System.out.println(response4_5.body());System.out.println(response4_5.headers());cookies = response4_5.cookies();//sapj2ee_star=cookies.get("sapj2ee_*");//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);// System.out.println(5);String url5 = "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx";Connection conn5 = Jsoup.connect(url5);conn5.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn5.header("Accept-Encoding", "gzip, deflate, sdch");conn5.header("Accept-Language", "zh-CN,zh;q=0.8");conn5.header("Connection", "keep-alive"); // conn5.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn5.header("Host", "bem.ffcs.cn:81");conn5.header("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default");conn5.header("Upgrade-Insecure-Requests", "1");conn5.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn5.cookie("JSESSIONID", JSESSIONID);conn5.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn5.cookie("MYSAPSSO2", MYSAPSSO2);conn5.method(Connection.Method.GET);Response response5 = conn5.timeout(10000).execute();System.out.println(response5.statusCode());System.out.println(response5.body());System.out.println(response5.headers());cookies = response5.cookies();//sapj2ee_star=cookies.get("sapj2ee_*");//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);Document doc = Jsoup.parse(response5.body());System.out.println(6);String url6 = "http://bem.ffcs.cn:81/hrs/ajax/common.ashx";Connection conn6 = Jsoup.connect(url6);conn6.header("Accept", "*/*");conn6.header("Accept-Encoding", "gzip, deflate, sdch");conn6.header("Accept-Language", "zh-CN,zh;q=0.8");conn6.header("Connection", "keep-alive"); // conn6.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn6.header("Host", "bem.ffcs.cn:81");conn6.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");conn6.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn6.cookie("JSESSIONID", JSESSIONID);conn6.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn6.cookie("MYSAPSSO2", MYSAPSSO2);conn6.method(Connection.Method.GET);Response response6 = conn6.timeout(10000).execute();System.out.println(response6.statusCode()); // System.out.println(response6.body());System.out.println(response6.headers());cookies = response6.cookies();//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);System.out.println(7);String url7 = "http://bem.ffcs.cn:81/hrs/ajax/FFCS.HumanResource.Work.OutUserWork,FFCS.HumanResource.ashx";Connection conn7 = Jsoup.connect(url7);conn7.header("Accept", "*/*");conn7.header("Accept-Encoding", "gzip, deflate, sdch");conn7.header("Accept-Language", "zh-CN,zh;q=0.8");conn7.header("Connection", "keep-alive"); // conn7.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn7.header("Host", "bem.ffcs.cn:81");conn7.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");conn7.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn7.cookie("JSESSIONID", JSESSIONID);conn7.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn7.cookie("MYSAPSSO2", MYSAPSSO2);conn7.method(Connection.Method.GET);Response response7 = conn7.timeout(10000).execute();System.out.println(response7.statusCode()); // System.out.println(response7.body());System.out.println(response7.headers());cookies = response7.cookies();//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);System.out.println("上班");///上班/Element form1=doc.getElementById("form1");Elements inputs = form1.getElementsByTag("input");System.out.println(inputs);Map<String,String> dataMap = new HashMap<String,String>();Iterator<Element> inputIt = inputs.iterator();while(inputIt.hasNext()){Element inputEle = inputIt.next();if(!"ibOff".equals(inputEle.attr("name"))){dataMap.put(inputEle.attr("name"), inputEle.attr("value"));}}Random rd = new Random();int xx = 3 + rd.nextInt(121-3);int yy = 9 + rd.nextInt(29-9);dataMap.put("ibOn.x", xx+""); //82dataMap.put("ibOn.y", yy+""); //22System.out.println(dataMap);try {Thread.sleep(2000);} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}System.out.println(8);String url8 = "http://bem.ffcs.cn:81/hrs/ajax/FFCS.HumanResource.Work.OutUserWork,FFCS.HumanResource.ashx?_method=AjaxCheckOnWork&_session=rw";Connection conn8 = Jsoup.connect(url8);conn8.header("Accept", "*/*");conn8.header("Accept-Encoding", "gzip, deflate");conn8.header("Accept-Language", "zh-CN,zh;q=0.8");conn8.header("Connection", "keep-alive"); // conn8.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn8.header("Content-Length","42");conn8.header("Content-Type","text/plain;charset=UTF-8");conn8.header("Host", "bem.ffcs.cn:81");conn8.header("Origin","http://bem.ffcs.cn:81");conn8.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");conn8.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn8.cookie("JSESSIONID",JSESSIONID);conn8.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn8.cookie("MYSAPSSO2", MYSAPSSO2);conn8.data("strUserNo",dataMap.get("pcUserno"));conn8.data("strUserName",dataMap.get("pcUsername"));conn8.method(Connection.Method.POST);Response response8 = conn8.timeout(10000).execute();System.out.println(response8.statusCode());System.out.println(response8.body());System.out.println(response8.headers());cookies = response8.cookies();//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);System.out.println(9);String url9 = "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx";Connection conn9 = Jsoup.connect(url9);conn9.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn9.header("Accept-Encoding", "gzip, deflate");conn9.header("Accept-Language", "zh-CN,zh;q=0.8");conn9.header("Cache-Control","max-age=0");//conn9.header("Connection", "keep-alive"); // conn9.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn9.header("Content-Length","515");conn9.header("Content-Type","application/x-www-form-urlencoded");conn9.header("Host", "bem.ffcs.cn:81");conn9.header("Origin","http://bem.ffcs.cn:81");conn9.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");conn9.header("Upgrade-Insecure-Requests", "1");conn9.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn9.cookie("JSESSIONID",JSESSIONID);conn9.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn9.cookie("MYSAPSSO2", MYSAPSSO2);conn9.data(dataMap);conn9.method(Connection.Method.POST);conn9.followRedirects(false);Response response9 = conn9.timeout(10000).execute();System.out.println(response9.statusCode());System.out.println(response9.body());System.out.println(response9.headers());cookies = response9.cookies();redirectUrl = response9.header("Location");//Location:/hrs/work/OutUserWorkList.aspx?id=17105468System.out.println(cookies);System.out.println(redirectUrl);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);if(redirectUrl != null){System.out.println(10);String url10 = redirectUrl;//http://bem.ffcs.cn:81/hrs/work/OutUserWorkList.aspx?id=17105468Connection conn10 = Jsoup.connect("http://bem.ffcs.cn:81"+url10);conn10.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn10.header("Accept-Encoding", "gzip, deflate, sdch");conn10.header("Accept-Language", "zh-CN,zh;q=0.8");conn10.header("Cache-Control","max-age=0");conn10.header("Connection", "keep-alive"); // conn10.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn10.header("Host", "bem.ffcs.cn:81");conn10.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");conn10.header("Upgrade-Insecure-Requests", "1");conn10.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn10.cookie("JSESSIONID", JSESSIONID);conn10.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn10.cookie("MYSAPSSO2", MYSAPSSO2);conn10.method(Connection.Method.GET);Response response10 = conn10.timeout(10000).execute();System.out.println(response10.statusCode());System.out.println(response10.body());System.out.println(response10.headers());cookies = response10.cookies();//sapj2ee_star=cookies.get("sapj2ee_*");//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);}} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace(System.out);}}}下班打卡
package htmlparse;import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.Map;import org.jsoup.Connection; import org.jsoup.Connection.Response; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements;public class OffCheck {public static void main(String[] arg0) throws IOException{// HttpURLConnection httpConn=null; // BufferedReader in=null; // PrintWriter out=null; // try { // URL url=new URL("http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default"); // httpConn=(HttpURLConnection)url.openConnection(); // httpConn.setRequestMethod("POST"); // httpConn.setDoInput(true); // httpConn.setDoOutput(true); // httpConn.setInstanceFollowRedirects(false); // // httpConn.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); // httpConn.setRequestProperty("Accept-Encoding", "gzip, deflate"); // httpConn.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8"); // httpConn.setRequestProperty("Cache-Control", "max-age=0"); // httpConn.setRequestProperty("Connection", "keep-alive"); // httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); // httpConn.setRequestProperty("Cookie", "ff_username=os.*******=ff_username; JSESSIONID=ID669715155DB0.22358644074085698End; sapj2ee_*=669715155"); // httpConn.setRequestProperty("Host", "eis.ffcs.cn"); // httpConn.setRequestProperty("Origin", "http://eis.ffcs.cn"); // httpConn.setRequestProperty("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default"); // httpConn.setRequestProperty("Upgrade-Insecure-Requests", "1"); // httpConn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36"); // // //發送post請求參數 // out=new PrintWriter(httpConn.getOutputStream()); // out.println("login_submit=on&login_do_redirect=1&no_cert_storing=on&j_user=os.*******&j_password=??????&j_authscheme=default"); // out.flush(); // // Map<String, List<String>> map = httpConn.getHeaderFields(); // // 遍歷所有的響應頭字段 // for (String key : map.keySet()) { // System.out.println(key + "--->" + map.get(key)); // } // // //讀取響應 // if(httpConn.getResponseCode()==302){ // StringBuffer content=new StringBuffer(); // String tempStr=""; // in=new BufferedReader(new InputStreamReader(httpConn.getInputStream())); // while((tempStr=in.readLine())!=null){ // content.append(tempStr); // } // System.out.println(new String(content.toString().getBytes(),Charset.forName("utf-8"))); // } // } catch (IOException e) { // e.printStackTrace(); // }finally{ // try{ // in.close(); // out.close(); // httpConn.disconnect(); // }catch(Exception e){ // e.printStackTrace(); // } // }Map<String, String> cookies = null;String sapj2ee_star = null;String JSESSIONID = null;String ASPdotNET_SessionId = null;String MYSAPSSO2 = null;System.out.println(1);String url = "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default";Connection conn = Jsoup.connect(url);conn.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn.header("Accept-Encoding", "gzip, deflate, sdch");conn.header("Accept-Language", "zh-CN,zh;q=0.8");conn.header("Connection", "keep-alive");conn.header("Cookie", "ff_username=os.*******=ff_username");//conn.header("Cookie", "ff_username=os.*******=ff_username; JSESSIONID=ID669715155DB0.22358644074085698End; sapj2ee_*=669715155");conn.header("Host", "eis.ffcs.cn");conn.header("Upgrade-Insecure-Requests", "1");conn.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn.method(Connection.Method.GET); // conn.followRedirects(false);Response response = conn.timeout(10000).execute();System.out.println(response.statusCode()); // System.out.println(response.body());System.out.println(response.headers());cookies = response.cookies();sapj2ee_star = cookies.get("sapj2ee_*");JSESSIONID = cookies.get("JSESSIONID");System.out.println(cookies); //sapj2ee_*=669715155; Version=1; Path=/ //JSESSIONID=ID669715155DB0.24023707681679896End; Version=1; Domain=.ffcs.cn; Path=/System.out.println(2);String url2 = "http://bem.ffcs.cn:81/mis/eislogin.aspx";Connection conn2 = Jsoup.connect(url2);conn2.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn2.header("Accept-Encoding", "gzip, deflate, sdch");conn2.header("Accept-Language", "zh-CN,zh;q=0.8");conn2.header("Connection", "keep-alive"); // conn2.header("Cookie", "ASP.NET_SessionId=1gjx3p23rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn2.header("Host", "bem.ffcs.cn:81");conn2.header("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default");conn2.header("Upgrade-Insecure-Requests", "1");conn2.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn2.cookie("JSESSIONID","ID669715155DB0.4105357846396225End");conn2.method(Connection.Method.GET);Response response2 = conn2.timeout(10000).execute();System.out.println(response2.statusCode()); // System.out.println(response2.body());System.out.println(response2.headers());cookies = response2.cookies();ASPdotNET_SessionId = cookies.get("ASP.NET_SessionId");System.out.println(cookies);System.out.println(3);String url3 = "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default";Connection conn3 = Jsoup.connect(url3);conn3.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn3.header("Accept-Encoding", "gzip, deflate");conn3.header("Accept-Language", "zh-CN,zh;q=0.8");conn3.header("Cache-Control","max-age=0");//conn3.header("Connection", "keep-alive"); // conn3.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie); // conn3.header("Content-Length","111");conn3.header("Content-Type","application/x-www-form-urlencoded");conn3.header("Host", "eis.ffcs.cn");conn3.header("Origin","http://eis.ffcs.cn");conn3.header("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default");conn3.header("Upgrade-Insecure-Requests", "1");conn3.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn3.cookie("ff_username","os.*******=ff_username");conn3.cookie("sapj2ee_*", sapj2ee_star);conn3.cookie("JSESSIONID", JSESSIONID);conn3.data("login_submit", "on");conn3.data("login_do_redirect", "1");conn3.data("no_cert_storing", "on");conn3.data("j_user", "os.*******");conn3.data("j_password", "??????");conn3.data("j_authscheme", "default");conn3.method(Connection.Method.POST);conn3.followRedirects(false);Response response3 = conn3.timeout(10000).execute();System.out.println(response3.statusCode()); // System.out.println(response3.body());System.out.println(response3.headers());cookies = response3.cookies();String redirectUrl = response3.header("Location");//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndMYSAPSSO2 = cookies.get("MYSAPSSO2");System.out.println(cookies);System.out.println(MYSAPSSO2);System.out.println(redirectUrl);System.out.println(4);//String url4 = "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default";String url4 = redirectUrl;Connection conn4 = Jsoup.connect(url4);conn4.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn4.header("Accept-Encoding", "gzip, deflate, sdch");conn4.header("Accept-Language", "zh-CN,zh;q=0.8");conn4.header("Cache-Control","max-age=0");//conn4.header("Connection", "keep-alive"); // conn4.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie); // conn4.header("Content-Length","111");conn4.header("Host", "eis.ffcs.cn");conn4.header("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default");conn4.header("Upgrade-Insecure-Requests", "1");conn4.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn4.cookie("ff_username","os.*******=ff_username");conn4.cookie("sapj2ee_*", sapj2ee_star);conn4.cookie("JSESSIONID", JSESSIONID);conn4.cookie("MYSAPSSO2", MYSAPSSO2);conn4.method(Connection.Method.GET);System.out.println(5);Response response4 = conn4.timeout(10000).execute();System.out.println(response4.statusCode()); // System.out.println(response4.body());System.out.println(response4.headers());cookies = response4.cookies();sapj2ee_star=cookies.get("sapj2ee_*");//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(5);String url5 = "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx";Connection conn5 = Jsoup.connect(url5);conn5.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn5.header("Accept-Encoding", "gzip, deflate, sdch");conn5.header("Accept-Language", "zh-CN,zh;q=0.8");conn5.header("Connection", "keep-alive"); // conn5.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn5.header("Host", "bem.ffcs.cn:81");conn5.header("Referer", "http://eis.ffcs.cn/irj/servlet/prt/portal/prtroot/com.sap.portal.navigation.portallauncher.default");conn5.header("Upgrade-Insecure-Requests", "1");conn5.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn5.cookie("JSESSIONID", JSESSIONID);conn5.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn5.cookie("MYSAPSSO2", MYSAPSSO2);conn5.method(Connection.Method.GET);Response response5 = conn5.timeout(10000).execute();System.out.println(response5.statusCode());System.out.println(response5.body());System.out.println(response5.headers());cookies = response5.cookies(); // sapj2ee_star=cookies.get("sapj2ee_*");//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);Document doc = Jsoup.parse(response5.body());System.out.println(6);String url6 = "http://bem.ffcs.cn:81/hrs/ajax/common.ashx";Connection conn6 = Jsoup.connect(url6);conn6.header("Accept", "*/*");conn6.header("Accept-Encoding", "gzip, deflate, sdch");conn6.header("Accept-Language", "zh-CN,zh;q=0.8");conn6.header("Connection", "keep-alive"); // conn6.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn6.header("Host", "bem.ffcs.cn:81");conn6.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");conn6.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn6.cookie("JSESSIONID", JSESSIONID);conn6.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn6.cookie("MYSAPSSO2", MYSAPSSO2);conn6.method(Connection.Method.GET);Response response6 = conn6.timeout(10000).execute();System.out.println(response6.statusCode());// System.out.println(response6.body());System.out.println(response6.headers());cookies = response6.cookies();//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(7);String url7 = "http://bem.ffcs.cn:81/hrs/ajax/FFCS.HumanResource.Work.OutUserWork,FFCS.HumanResource.ashx";Connection conn7 = Jsoup.connect(url7);conn7.header("Accept", "*/*");conn7.header("Accept-Encoding", "gzip, deflate, sdch");conn7.header("Accept-Language", "zh-CN,zh;q=0.8");conn7.header("Connection", "keep-alive"); // conn7.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn7.header("Host", "bem.ffcs.cn:81");conn7.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");conn7.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn7.cookie("JSESSIONID", JSESSIONID);conn7.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn7.cookie("MYSAPSSO2", MYSAPSSO2);conn7.method(Connection.Method.GET);Response response7 = conn7.timeout(10000).execute();System.out.println(response7.statusCode());// System.out.println(response7.body());System.out.println(response7.headers());cookies = response7.cookies();//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println("下班");///下班/Element form1=doc.getElementById("form1");Elements inputs = form1.getElementsByTag("input");System.out.println(inputs);Map<String,String> dataMap = new HashMap<String,String>();Iterator<Element> inputIt = inputs.iterator();while(inputIt.hasNext()){Element inputEle = inputIt.next();if(!"ibOff".equals(inputEle.attr("name"))){dataMap.put(inputEle.attr("name"), inputEle.attr("value"));}}System.out.println(dataMap);// dataMap.put("ibOn.x", "66"); // dataMap.put("ibOn.y", "27");try {Thread.sleep(1000);} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}System.out.println(8);String url8 = "http://bem.ffcs.cn:81/hrs/ajax/FFCS.HumanResource.Work.OutUserWork,FFCS.HumanResource.ashx?_method=AjaxCheckOffTime&_session=rw";Connection conn8 = Jsoup.connect(url8);conn8.header("Accept", "*/*");conn8.header("Accept-Encoding", "gzip, deflate");conn8.header("Accept-Language", "zh-CN,zh;q=0.8");conn8.header("Connection", "keep-alive"); // conn8.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie); // conn8.header("Content-Length","19");conn8.header("Content-Type","text/plain;charset=UTF-8");conn8.header("Host", "bem.ffcs.cn:81");conn8.header("Origin","http://bem.ffcs.cn:81");conn8.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");conn8.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn8.cookie("JSESSIONID",JSESSIONID);conn8.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn8.cookie("MYSAPSSO2", MYSAPSSO2);System.out.println(dataMap.get("pcUserno"));conn8.data("strUserno",dataMap.get("pcUserno"));conn8.method(Connection.Method.POST);Response response8 = conn8.timeout(10000).execute();System.out.println(response8.statusCode());System.out.println(response8.body());System.out.println(response8.headers());cookies = response8.cookies();//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(9);String url9 = "http://bem.ffcs.cn:81/hrs/ajax/FFCS.HumanResource.Work.OutUserWork,FFCS.HumanResource.ashx?_method=AjaxGetWorkHour&_session=rw";Connection conn9 = Jsoup.connect(url9);conn9.header("Accept", "*/*");conn9.header("Accept-Encoding", "gzip, deflate");conn9.header("Accept-Language", "zh-CN,zh;q=0.8");// conn9.header("Cache-Control","max-age=0");//conn9.header("Connection", "keep-alive"); // conn9.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie); // conn9.header("Content-Length","40");conn9.header("Content-Type","text/plain;charset=UTF-8");conn9.header("Host", "bem.ffcs.cn:81");conn9.header("Origin","http://bem.ffcs.cn:81");conn9.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");// conn9.header("Upgrade-Insecure-Requests", "1");conn9.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn9.cookie("JSESSIONID",JSESSIONID);conn9.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn9.cookie("MYSAPSSO2", MYSAPSSO2);System.out.println(dataMap.get("pcDeptid"));System.out.println(dataMap.get("pcUserno"));conn9.data("strDeptID",dataMap.get("pcDeptid"));conn9.data("strUserNO",dataMap.get("pcUserno"));conn9.method(Connection.Method.POST);// conn9.followRedirects(false);Response response9 = conn9.timeout(10000).execute();System.out.println(response9.statusCode());System.out.println(response9.body());System.out.println(response9.headers());cookies = response9.cookies();System.out.println(cookies); // redirectUrl = response9.header("Location"); // //Location:/hrs/work/OutUserWorkList.aspx?id=17105468// System.out.println(redirectUrl); //System.out.println(10);String url10 = "http://bem.ffcs.cn:81/hrs/work/Effort-Admin-Hour-Input-Plus.aspx?userno="+dataMap.get("pcUserno")+"&work=2";Connection conn10 = Jsoup.connect(url10);conn10.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn10.header("Accept-Encoding", "gzip, deflate, sdch");conn10.header("Accept-Language", "zh-CN,zh;q=0.8"); // conn10.header("Cache-Control","max-age=0");//conn10.header("Connection", "keep-alive"); // conn10.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie); // conn10.header("Content-Length","515"); // conn10.header("Content-Type","application/x-www-form-urlencoded");conn10.header("Host", "bem.ffcs.cn:81"); // conn10.header("Origin","http://bem.ffcs.cn:81");conn10.header("Referer", "http://bem.ffcs.cn:81/hrs/work/OutUserWork.aspx");conn10.header("Upgrade-Insecure-Requests", "1");conn10.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn10.cookie("JSESSIONID",JSESSIONID);conn10.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn10.cookie("MYSAPSSO2", MYSAPSSO2);conn10.method(Connection.Method.GET);Response response10 = conn10.timeout(10000).execute();System.out.println(response10.statusCode());System.out.println(response10.body());System.out.println(response10.headers());cookies = response10.cookies();System.out.println(cookies);System.out.println(response10.body());Document doc2 = Jsoup.parse(response10.body());Element form2=doc2.getElementById("form1");Elements inputs2 = form2.getElementsByTag("input");System.out.println(inputs2);Map<String,String> dataMap2 = new HashMap<String,String>();Iterator<Element> inputIt2 = inputs2.iterator();boolean hasAdd = false;while(inputIt2.hasNext()){Element inputEle2 = inputIt2.next();String inputName = inputEle2.attr("name");if(hasAdd == false && inputName.startsWith("input-")){dataMap2.put(inputEle2.attr("name"), "8");hasAdd = true;}else if(hasAdd == true && inputName.startsWith("input-")){dataMap2.put(inputEle2.attr("name"), "0");}else if(inputName.startsWith("sum-day-")){dataMap2.put(inputEle2.attr("name"), "8");}else{dataMap2.put(inputEle2.attr("name"), inputEle2.attr("value"));}}System.out.println(dataMap2);System.out.println(11);String url11 = "http://bem.ffcs.cn:81/hrs/work/Effort-Admin-Hour-Input-Plus.aspx?userno="+dataMap.get("pcUserno")+"&work=2";Connection conn11 = Jsoup.connect(url11);conn11.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn11.header("Accept-Encoding", "gzip, deflate");conn11.header("Accept-Language", "zh-CN,zh;q=0.8");conn11.header("Cache-Control","max-age=0");//conn11.header("Connection", "keep-alive"); // conn11.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie); // conn11.header("Content-Length","515");conn11.header("Content-Type","application/x-www-form-urlencoded");conn11.header("Host", "bem.ffcs.cn:81");conn11.header("Origin","http://bem.ffcs.cn:81");conn11.header("Referer", "http://bem.ffcs.cn:81/hrs/work/Effort-Admin-Hour-Input-Plus.aspx?userno="+dataMap.get("pcUserno")+"&work=2");conn11.header("Upgrade-Insecure-Requests", "1");conn11.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn11.cookie("JSESSIONID",JSESSIONID);conn11.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn11.cookie("MYSAPSSO2", MYSAPSSO2);conn11.data(dataMap2);conn11.method(Connection.Method.POST);conn11.followRedirects(false);Response response11 = conn11.timeout(10000).execute();System.out.println(response11.statusCode());System.out.println(response11.body());System.out.println(response11.headers());cookies = response11.cookies();System.out.println(cookies);String redirectUrl2 = response11.header("Location");//Location:/hrs/work/OutUserWorkList.aspx?id=18098707&flag=0System.out.println(redirectUrl2);if(redirectUrl2 != null){System.out.println(12);String url12 = "http://bem.ffcs.cn:81"+redirectUrl2;//http://bem.ffcs.cn:81/hrs/work/OutUserWorkList.aspx?id=17105468Connection conn12 = Jsoup.connect(url12);conn12.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");conn12.header("Accept-Encoding", "gzip, deflate, sdch");conn12.header("Accept-Language", "zh-CN,zh;q=0.8");conn12.header("Cache-Control","max-age=0");conn12.header("Connection", "keep-alive"); // conn12.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn12.header("Host", "bem.ffcs.cn:81");conn12.header("Referer", "http://bem.ffcs.cn:81/hrs/work/Effort-Admin-Hour-Input-Plus.aspx?"+dataMap.get("pcUserno")+"&work=2");conn12.header("Upgrade-Insecure-Requests", "1");conn12.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn12.cookie("JSESSIONID", JSESSIONID);conn12.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn12.cookie("MYSAPSSO2", MYSAPSSO2);conn12.method(Connection.Method.GET);Response response12 = conn12.timeout(10000).execute();System.out.println(response12.statusCode());System.out.println(response12.body());System.out.println(response12.headers());cookies = response12.cookies();//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);System.out.println(13);String url13 = "http://bem.ffcs.cn:81/hrs/js/AllJs.aspx";//http://bem.ffcs.cn:81/hrs/work/OutUserWorkList.aspx?id=17105468Connection conn13 = Jsoup.connect(url13);conn13.header("Accept", "*/*");conn13.header("Accept-Encoding", "gzip, deflate, sdch");conn13.header("Accept-Language", "zh-CN,zh;q=0.8");conn13.header("Connection", "keep-alive"); // conn13.header("Cookie", "ASP.NET_SessionId=1gjx3p33rxfd0kr0whfcv355; JSESSIONID=ID669715155DB0.22358644074085698End; MYSAPSSO2="+cookie);conn13.header("Host", "bem.ffcs.cn:81");conn13.header("Referer", "http://bem.ffcs.cn:81"+redirectUrl2);conn13.header("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36");conn13.cookie("JSESSIONID", JSESSIONID);conn13.cookie("ASP.NET_SessionId", ASPdotNET_SessionId);conn13.cookie("MYSAPSSO2", MYSAPSSO2);conn13.method(Connection.Method.GET);Response response13 = conn13.timeout(10000).execute();System.out.println(response13.statusCode());System.out.println(response13.body());System.out.println(response13.headers());cookies = response13.cookies();//Cookie:ff_username=os.*******=ff_username; sapj2ee_*=669715155; JSESSIONID=ID669715155DB0.8915172846308779EndSystem.out.println(cookies);}System.out.println(" 1 "+sapj2ee_star+" 2 "+JSESSIONID+" 3 "+ ASPdotNET_SessionId + " 4 "+MYSAPSSO2);}}總結
- 上一篇: 肖维勒准则matlab_肖维勒准则.PP
- 下一篇: 软考高项-质量管理论文范文