NoNameCracksInc

Parser backup

Jan 29th, 2014
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.62 KB | None | 0 0
  1. import org.jsoup.*;
  2. import java.io.*;
  3. import org.jsoup.nodes.*;
  4. import java.net.*;
  5.  
  6. public class Analyser extends Adapter implements Runnable
  7. {
  8.         public String command;
  9.         public static int i;
  10.        
  11.         public static void main(String args[]) throws IOException,InterruptedException
  12.         {
  13.                 Analyser obj=new Analyser();
  14.                 obj.core();
  15.         }
  16.        
  17.         public void core() throws IOException
  18.         {
  19.                 BufferedReader scan=new BufferedReader(new InputStreamReader(System.in));
  20.                 Thread time=new Thread(new Analyser());
  21.                
  22.                 time.start();
  23.                 connect("");            
  24.                 do
  25.                 {
  26.                         command=scan.readLine();
  27.                         switches();
  28.                 }
  29.                 while(!command.equals(":quit"));
  30.         }
  31.        
  32.         public void switches() throws IOException
  33.         {
  34.                 if(connected)
  35.                 {
  36.                         if(command.contains(":get"))
  37.                         {
  38.                                 if(command.contains("-node"))
  39.                                 {
  40.                                         System.out.println(con.nodeName());
  41.                                 }      
  42.                                
  43.                                 if(command.contains("-tag"))
  44.                                 {
  45.                                         System.out.println(con.tagName());
  46.                                 }
  47.                                
  48.                                 if(command.contains("-source"))
  49.                                 {
  50.                                         System.out.println(con.html());
  51.                                 }
  52.                                
  53.                                 if(command.contains("-txt"))
  54.                                 {
  55.                                         System.out.println(con.text());
  56.                                 }
  57.                                 if(command.contains("-hash"))
  58.                                 {
  59.                                         System.out.println(con.hashCode());
  60.                                 }
  61.                                 if(command.contains("-title"))
  62.                                 {
  63.                                         System.out.println(con.title());
  64.                                 }
  65.                                 if(command.contains("-ip"))
  66.                                 {
  67.                                         InetAddress ip=InetAddress.getByName(website);
  68.                                         System.out.println(ip);
  69.                                 }
  70.                                 if(command.contains("-session"))
  71.                                 {
  72.                                         System.out.println(i+" seconds");
  73.                                 }
  74.                                 if(command.contains("-jvs"))
  75.                                 {
  76.                                         String src=con.html();
  77.                                        
  78.                                         if(src.contains("<script>"))
  79.                                         {
  80.                                                 System.out.println("jvs: true");
  81.                                         }
  82.                                         else
  83.                                         {
  84.                                                 System.out.println("jvs: false");
  85.                                         }
  86.                                 }
  87.                                 if(command.contains("-css"))
  88.                                 {
  89.                                         String src=con.html();
  90.                                        
  91.                                         if(src.contains("<style>"))
  92.                                         {
  93.                                                 System.out.println("css: true");
  94.                                         }
  95.                                         else
  96.                                         {
  97.                                                 System.out.println("css: false");
  98.                                         }
  99.                                 }
  100.                         }
  101.                         if(command.equals(":reload"))
  102.                         {
  103.                             disconnect();
  104.                         }
  105.                         if(command.equals(":cls"))
  106.                         {
  107.                                 for(int c=0;c<=100;c++)
  108.                                 {
  109.                                         System.out.println();
  110.                                 }
  111.                         }
  112.                         if(command.contains(":arg"))
  113.                         {
  114.                             int length=command.length();
  115.                             String arg=command.substring(5,length);
  116.                            
  117.                             connect(arg);
  118.                         }
  119.                 }
  120.         }
  121.        
  122.         public void run()
  123.         {
  124.             try
  125.                 {
  126.                 for(i=0;i>=0;i++)
  127.                     {
  128.                         Thread.sleep(1000);
  129.                     }
  130.             }
  131.             catch(InterruptedException e)
  132.             {
  133.                 System.out.println(e.getMessage()+" -thread interrupted");
  134.             }
  135.          }
  136. }
  137.  
  138. class Adapter
  139. {
  140.     public static boolean connected=false;
  141.     public static String input;
  142.     public static String website;
  143.     public static Document con;
  144.    
  145.     public static void connect(String argument) throws IOException
  146.     {
  147.             BufferedReader get=new BufferedReader(new InputStreamReader(System.in));
  148.            
  149.             do
  150.             {
  151.              System.out.print("["+argument+"]"+" $");
  152.              input=get.readLine();
  153.              
  154.              if(input.contains(":connect www"))
  155.              {
  156.                      int length=input.length();
  157.                      website=input.substring(9,length);
  158.                      con=Jsoup.connect("http://"+website+argument).get();
  159.                      connected=true;
  160.                      System.out.println("connected\n");
  161.                      return;
  162.              }
  163.              else
  164.              {
  165.                      System.out.println("Wrong syntax.Use command [:connect websitename]");
  166.              }
  167.             }
  168.             while(!connected==true);
  169.     }
  170.    
  171.     public static void disconnect() throws IOException
  172.     {
  173.         System.out.println("disconnected\n");
  174.         connected=false;
  175.         connect("");
  176.         return;
  177.     }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment