Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author NghiaDTSE05330
- */
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.InputStreamReader;
- import java.net.HttpURLConnection;
- import java.net.URL;
- import javax.net.ssl.HttpsURLConnection;
- public class JavaApplication21 {
- private final String USER_AGENT = "Mozilla/5.0";
- public static void main(String[] args) throws Exception {
- JavaApplication21 http = new JavaApplication21();
- System.out.println("Testing 1 - Send Http GET request");
- http.sendGet();
- }
- // HTTP GET request
- private void sendGet() throws Exception {
- boolean result=false;
- while (!result){
- String url = "http://128.199.190.23:8001/?input=Tzo2OiJPYmplY3QiOjI6e3M6NzoiamFja3BvdCI7TjtzOjU6ImVudGVyIjtzOjE3OiI2OSA1NiA5MCAxNCA0MCAxNiI7fQ%3D%3D&btn-submit=go";
- URL obj = new URL(url);
- HttpURLConnection con = (HttpURLConnection) obj.openConnection();
- // optional default is GET
- con.setRequestMethod("GET");
- //add request header
- con.setRequestProperty("User-Agent", USER_AGENT);
- int responseCode = con.getResponseCode();
- BufferedReader in = new BufferedReader(
- new InputStreamReader(con.getInputStream()));
- String inputLine;
- StringBuffer response = new StringBuffer();
- while ((inputLine = in.readLine()) != null) {
- response.append(inputLine);
- }
- in.close();
- //print result
- if (response.toString().indexOf("Wrong! True Six Numbers Are:")==0) {
- System.out.println(response.toString());
- result=true;
- }
- else {
- System.out.println(response.toString().substring(639, 656));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement