SHARE
TWEET

Untitled

finalshare Jul 13th, 2017 162 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. /**
  7.  *
  8.  * @author NghiaDTSE05330
  9.  */
  10. import java.io.BufferedReader;
  11. import java.io.DataOutputStream;
  12. import java.io.InputStreamReader;
  13. import java.net.HttpURLConnection;
  14. import java.net.URL;
  15.  
  16. import javax.net.ssl.HttpsURLConnection;
  17.  
  18. public class JavaApplication21 {
  19.  
  20.     private final String USER_AGENT = "Mozilla/5.0";
  21.  
  22.     public static void main(String[] args) throws Exception {
  23.  
  24.         JavaApplication21 http = new JavaApplication21();
  25.  
  26.         System.out.println("Testing 1 - Send Http GET request");
  27.         http.sendGet();
  28.  
  29.  
  30.     }
  31.  
  32.     // HTTP GET request
  33.     private void sendGet() throws Exception {
  34.                 boolean result=false;
  35.                 while (!result){
  36.         String url = "http://128.199.190.23:8001/?input=Tzo2OiJPYmplY3QiOjI6e3M6NzoiamFja3BvdCI7TjtzOjU6ImVudGVyIjtzOjE3OiI2OSA1NiA5MCAxNCA0MCAxNiI7fQ%3D%3D&btn-submit=go";
  37.  
  38.         URL obj = new URL(url);
  39.         HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  40.                    
  41.         // optional default is GET
  42.         con.setRequestMethod("GET");
  43.  
  44.         //add request header
  45.         con.setRequestProperty("User-Agent", USER_AGENT);
  46.  
  47.         int responseCode = con.getResponseCode();
  48.  
  49.         BufferedReader in = new BufferedReader(
  50.                 new InputStreamReader(con.getInputStream()));
  51.         String inputLine;
  52.         StringBuffer response = new StringBuffer();
  53.  
  54.         while ((inputLine = in.readLine()) != null) {
  55.             response.append(inputLine);
  56.         }
  57.         in.close();
  58.  
  59.         //print result
  60.                 if (response.toString().indexOf("Wrong! True Six Numbers Are:")==0) {
  61.                     System.out.println(response.toString());
  62.                     result=true;
  63.                 }
  64.                 else {
  65.                     System.out.println(response.toString().substring(639, 656));
  66.                 }
  67.                 }
  68.     }
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top