How to log in 360 and check in automatically daily
The difficulty is mainly focused on landing here, began to catch the packet found 360 login verification is very troublesome, but later found a simple method.
Because I installed 360 security guard, found that click on the Gold button can directly verify the login, haha ~ so httpclient direct get this URL can create a cookie to complete the landing ~
The above said not understand, look at the picture:
1 Importjava.io.IOException;2 ImportJava.util.Map;3 ImportJava.util.regex.Matcher;4 ImportJava.util.regex.Pattern;5 6 ImportNet.sf.json.JSONObject;7 8 ImportOrg.apache.http.Header;9 Importorg.apache.http.HttpEntity;Ten ImportOrg.apache.http.HttpResponse; One Importorg.apache.http.client.ClientProtocolException; A ImportOrg.apache.http.client.methods.HttpGet; - ImportOrg.apache.http.client.methods.HttpPost; - ImportOrg.apache.http.client.params.CookiePolicy; the ImportOrg.apache.http.client.params.HttpClientParams; - Importorg.apache.http.impl.client.DefaultHttpClient; - Importorg.apache.http.util.EntityUtils; - ImportOrg.apache.log4j.Logger; + - Importcom.kae.common.CustomerHttpClient; + ImportCom.kae.common.DummyRedirectHandler; A at /** - * - * @ClassName: Jifen360 - * @Description: 360 points - * @authorkaedeen.com - * @date 2013-11-22 pm 9:28:24 in * - */ to + Public classJifen360 { - the Private Static FinalLogger Logger = Logger.getlogger (Jifen360.class); * $ Private StaticDefaulthttpclient httpclient =NULL;//HttpClient ObjectPanax Notoginseng - Private StaticHttpResponse response =NULL; the + PrivateString url = ""; A the PublicJifen360 (String url) { + This. url =URL; - } $ $ /** - * Registration - * the * @return - */Wuyi@SuppressWarnings ({"Deprecation", "rawtypes" }) the Public BooleansignIn () { - BooleanFlag =false; Wu -HttpClient =Newdefaulthttpclient (); About //Set Cookie Policy $ Httpclientparams.setcookiepolicy (Httpclient.getparams (), - cookiepolicy.browser_compatibility); - -Httpclient.setredirecthandler (NewDummyredirecthandler ()); A +HttpGet HttpGet =Newhttpget (URL); the - Try { $Response =Httpclient.execute (httpget); the}Catch(clientprotocolexception e) { the //TODO auto-generated Catch block theLogger.error ("Jifen360 signIn clientprotocolexception:" +e.tostring ()); the}Catch(IOException e) { - //TODO auto-generated Catch block inLogger.error ("Jifen360 signIn IOException:" +e.tostring ()); the}finally { the Httpget.abort (); About } the theString token =GetToken (); the + //Request a sign -in link -String signinurl= "http://jifen.360.cn/safe/ajax_signin.html?token=" +token; the BayiHttpPost HttpPost =NewHttpPost (signinurl); theHttppost.setheader ("Accept", "*/*"); theHttppost.setheader ("Accept-language", "zh-cn,zh;q=0.8,en;q=0.6,ja;q=0.4,zh-tw;q=0.2"); -Httppost.setheader ("Content-type", "application/x-www-form-urlencoded"); -Httppost.setheader ("Host", "jifen.360.cn"); theHttppost.setheader ("Origin", "http://jifen.360.cn"); theHttppost.setheader ("Proxy-connection", "keep-alive"); theHttppost.setheader ("Referer", "Http://jifen.360.cn/safe?src=safe"); theHttppost.setheader ("User-agent", "mozilla/5.0 (Windows NT 6.1) applewebkit/537.36 (khtml, like Gecko) chrome/ 31.0.1650.57 safari/537.36 "); -Httppost.setheader ("X-requested-with", "XMLHttpRequest"); the the Try { the //Get the check-in answer content94Response =Httpclient.execute (httppost); theHttpentity httpentity =response.getentity (); theString Responsejsonstr =entityutils.tostring (httpentity); the 98 //Request Example About //{"errno": 0, "errmsg": "", "data": {"Dayslen": 1, "Score": 2, "Signin_count": 608904}} successfully - //{"errno": 1, "errmsg": "\u60a8\u4eca\u5929\u5df2\u7ecf\u7b7e\u8fc7\u5230\u4e86~", "Data": ""} failed101 102Logger.info ("Jifen360 request sign-in link responsejsonstr:" +responsejsonstr);103 104Map map =Jsonobject.fromobject (RESPONSEJSONSTR); the intCode= (Integer) map.get ("errno");106 107 if(0==code) {108flag=true;109Logger.info ("Jifen360 sign-in success! "); the}Else{111Logger.info ("Jifen360 has signed up today!") "); the }113 the}Catch(Exception e) { theLogger.error ("Jifen360 signIn request sign-in link failed:" +e.tostring ()); the return false;117}finally {118 Httppost.abort ();119 } - 121 122 returnFlag;123 }124 the /**126 * Get 302 Jump127 * - * @return129 */ the PrivateString getredirectlocation () {131Header Locationheader = Response.getfirstheader ("Location"); the if(Locationheader = =NULL) {133 return NULL;134 }135 returnLocationheader.getvalue ();136 }137 138 /**139 * Get token $ * 141 * @return142 */143 PrivateString GetToken () {144 145String RedirectURL =getredirectlocation ();146 147String token = "";148 149String responsebody =Customerhttpclient.get (httpclient, redirecturl); Max //System.out.println (responsebody);151 thePattern pattern1 = Pattern.compile ("token\": \ "(. *) \", \ "Mall_tpl");153Matcher M1 =Pattern1.matcher (responsebody);154 if(M1.find ()) {155token = M1.group (1);156Logger.info ("Jifen360 token:" +token);157}Else {158Logger.error ("Jifen360 360 get the token failed! ");159 } the 161 returntoken;162 }163 164}
360 Daily Auto Sign-in, collect points (Java httpclient4.x)