Skip to content

Instantly share code, notes, and snippets.

@atechcrew
Created July 9, 2018 13:37
Show Gist options
  • Save atechcrew/c543947d55a72282535569360a94e609 to your computer and use it in GitHub Desktop.
Save atechcrew/c543947d55a72282535569360a94e609 to your computer and use it in GitHub Desktop.
Simple code to get html code of web site using java code. Get website html code simply using scanner in java.
import java.net.URL;
import java.util.Scanner;
public class GetHTML {
public static void main(String args[]) {
try {
URL url = new URL("http://snooker.org");
Scanner scan = new Scanner(url.openStream());
while(scan.hasNext()) {
System.out.println(scan.nextLine());
}
scan.close();
}catch(Exception e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment