Advertisement
Guest User

url validator

a guest
Apr 18th, 2019
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.24 KB | None | 0 0
  1. v//import java.util.Math;
  2. import java.net.*;
  3. import java.io.*;
  4.  
  5. public class GoogleURL{
  6.   public  static char[] chars = {'0','1','2','3','4','5','6','7','8','9',
  7.   'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
  8.   'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
  9.   '_'};
  10.   public static char[] letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
  11.   'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',};
  12.   public static char[] sChars = {'-'};
  13.   public static String url_base = "https://lh3.googleusercontent.com/";
  14.   //this is narrowed down to 3 random letters to save on time as it always appears to have 8 'A' chars
  15.   public static String counter = "AAAAAAAA";
  16.   public static String end = "CLABGAYYCw/";
  17.   public static String temp;
  18.  
  19.   public static int rand(int min, int max){
  20.     return (int)(Math.random() * max + min);
  21.   }
  22.  
  23.   public static String build(boolean debug){
  24.     temp = "";
  25.     temp += url_base;
  26.     temp += '-';
  27.     for(int i = 0;i<11;i++){
  28.       temp += chars[rand(0,62)];
  29.     }
  30.     temp += '/';
  31.     for(int i = 0;i<11;i++){
  32.       temp += chars[rand(0,63)];
  33.     }
  34.     temp += '/';
  35.     temp += counter;
  36.     for(int i = 0;i<3;i++){
  37.       temp += letters[rand(0,52)];
  38.     }
  39.     temp += '/';
  40.     for(int i = 0;i<33;i++){
  41.       temp += chars[rand(0,63)];
  42.     }
  43.     temp += end;
  44.     if(debug){
  45.       System.out.println(temp);
  46.     }
  47.     return temp;
  48.   }
  49.  
  50.   public static int getResponseCode(String str){
  51.     try{
  52.       URL u = new URL (str);
  53.       HttpURLConnection huc =  ( HttpURLConnection )  u.openConnection ();
  54.       huc.setRequestMethod ("GET");  //OR  huc.setRequestMethod ("HEAD");
  55.       huc.connect () ;
  56.       int code = huc.getResponseCode() ;
  57.       return code;
  58.     }catch(Exception e){
  59.       System.out.println(e);
  60.       return -1;
  61.     }
  62.   }
  63.  
  64.   public static void main(String[] args){
  65.     while(1!=2){
  66.       String str = build(false);
  67.       int test = getResponseCode(str);
  68.       if(test == 200){
  69.         System.out.println(str);
  70.         return;
  71.       }
  72.     }
  73.   }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement