import org.jsoup.*; import java.io.*; import org.jsoup.nodes.*; import java.net.*; public class Analyser implements Runnable { public boolean connected=false; public String full_line; public String command; public Document con; public String website; public static int i; public static void main(String args[]) throws IOException,InterruptedException { Analyser obj=new Analyser(); obj.core(); } public void core() throws IOException { BufferedReader scan=new BufferedReader(new InputStreamReader(System.in)); Thread t=new Thread(new Analyser()); t.start(); connect(); do { command=scan.readLine(); switches(); } while(!command.equals(":quit")); } public void connect() throws IOException { System.out.print("$"); BufferedReader get=new BufferedReader(new InputStreamReader(System.in)); do { full_line=get.readLine(); if(full_line.contains(":connect")) { int length=full_line.length(); website=full_line.substring(10,length); con=Jsoup.connect("http://"+website).get(); connected=true; System.out.println("connected"); return; } else { System.out.println("Wrong syntax.Use command [:connect websitename]."); } } while(!full_line.contains(":connect")); } public void switches() throws IOException { if(connected) { if(command.contains(":get")) { if(command.contains("-node")) { System.out.println(con.nodeName()); } if(command.contains("-tag")) { System.out.println(con.tagName()); } if(command.contains("-source")) { System.out.println(con.html()); } if(command.contains("-txt")) { System.out.println(con.text()); } if(command.contains("-hash")) { System.out.println(con.hashCode()); } if(command.contains("-title")) { System.out.println(con.title()); } if(command.contains("-ip")) { InetAddress ip=InetAddress.getByName(website); System.out.println(ip); } if(command.contains("-session")) { System.out.println(Analyser.i+" seconds"); } if(command.contains("jvs")) { String src=con.html(); if(src.contains("