httpclient simulates login (use js to set cookies) Copy code The code is as follows: document.cookie='utmpnum=51;path=/;domain=.' window.location.host document.cookie='utmpkey= 20154732;path=/;domain=.' window.location.host document.cookie='utmpuserid=yay;path=/;domain=.' window.location.host</ script> <br><meta http-equiv='Refresh' content='0; url=/firstpage.php'> <br> </div> <br>h4ttpclient 4.3: <br><br>The simplest The method is to customize an httpclient through the obtained cookie. According to the above example, the method is as follows: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="86" class="copybut" id="copybut86" onclick="doCopy('code86')"><u>Copy the code </u></a></span> The code is as follows: </div> <div class="codebody" id="code86"> <br>CookieStore cookieStore = new BasicCookieStore(); <br><br>for (int i = 0; i < 3; i ) { <BR>String name; <BR>String value; <BR> int flag=s.indexOf("document.cookie"); <BR>s=s.substring(flag 17); <BR>flag=s.indexOf('='); <BR>name=s.substring( 0, flag); <BR>value=s.substring(flag 1, s.indexOf(';')); <BR>BasicClientCookie cookie = new BasicClientCookie(name, <BR>value); <BR>cookie.setVersion (0); <BR>cookie.setDomain(".www.zju88.org"); //This URL corresponds to <span style="font-family: Arial, Helvetica, sans-serif;">window Return value of .location.host</span> <br>cookie.setPath("/"); <br>cookieStore.addCookie(cookie); <br>} <br>// Set the store <br>CloseableHttpClient httpclient = HttpClients.custom() <br>.setDefaultCookieStore(cookieStore) <br>.build(); <br> </div> <br>android: <br><br>I searched for a long time but couldn’t find the corresponding method above. API, you can only add cookies before each visit <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="78059" class="copybut" id="copybut78059" onclick="doCopy('code78059')"><u>Copy code</u></a></span> The code is as follows:</div> <div class="codebody" id="code78059"> <br>String cookie=""; <br>for (int i = 0; i < 3; i ) { <br>String name; <br>String value; <br>int flag=s.indexOf("document. cookie"); <br>s=s.substring(flag 17); <br>flag=s.indexOf('='); <br>name=s.substring(0, flag); <br>value= s.substring(flag 1, s.indexOf(';')); <br>cookie =name "=" value; <br>if(i!=2) <br>cookie =";"; <br> } <br><br>/* <br>* Every time you visit the network <br>*/ <br>HttpGet httpget = new HttpGet(url); <br>httpget.addHeader("Cookie",cookie); <br>//If there are already cookies in httpclient, you may need to set the cookie policy of httpclient. For details, please check the official API (: <br>HttpResponse response = httpclient.execute(httpget); <br> </div> <br>ps: If so With java SE, you can also use the htmlunit class, which will execute js.