daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Feb 17th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Scanner;
  6.  
  7. public class Main {
  8.  
  9.     static List<String> list = new ArrayList<>();
  10.     static int co = 0;
  11.     public static void main(String[] args) {
  12.  
  13.         String content = null;
  14.         List<String> array = new ArrayList<>();
  15.         URLConnection connection = null;
  16.         long start = System.currentTimeMillis();
  17.         try {
  18.             connection = new URL("https://hse.ru").openConnection();
  19.             Scanner scanner = new Scanner(connection.getInputStream());
  20.             scanner.useDelimiter("\\Z");
  21.             content = scanner.next();
  22.             scanner.close();
  23.         } catch (Exception ex) {
  24.             ex.printStackTrace();
  25.         }
  26.         StringBuilder stringBuilder = new StringBuilder(content);
  27.         //System.out.println(content);
  28.         //qwe(stringBuilder);
  29.         findURL(stringBuilder);
  30.  
  31.         StringBuilder str = new StringBuilder("tfoygf2 ==jhv 12 gfvjvl 123 gpg 12 dfjkvbhe 12 md fkb1122 mncb1 2n  bphbp12    kjb1 12");
  32.         //qwee(str);
  33.         System.out.println(list.size());
  34.     }
  35.  
  36.     static void qwe(StringBuilder stringBuilder){
  37.  
  38.         int i = stringBuilder.indexOf("</section>");
  39.         do{
  40.             stringBuilder = stringBuilder.delete(0,i+10);
  41.             i = stringBuilder.indexOf("</section>");
  42.  
  43.         }while (i!=-1);
  44.     }
  45.     static void qwee(StringBuilder stringBuilder){
  46.  
  47.         int i = stringBuilder.indexOf("12");
  48.         do{
  49.             stringBuilder = stringBuilder.delete(0,i+2);
  50.             i = stringBuilder.indexOf("12");
  51.  
  52.         }while (i!=-1);
  53.     }
  54.  
  55.     static void findURL(StringBuilder stringBuilder){
  56.         int i;
  57.         do{
  58.         i = stringBuilder.indexOf("a href=\"");
  59.         i+=8;
  60.         int j = i;
  61.         do{
  62.             j++;
  63.         }while (stringBuilder.charAt(j)!='\"');
  64.         String str = stringBuilder.substring(i,j);
  65.         list.add(str);
  66.         stringBuilder = stringBuilder.delete(0,i + 8 + j);
  67.         }while (i!=-1);
  68.     }
  69.  
  70. }
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