Created
May 10, 2017 18:00
-
-
Save guffyWave/2a86c8570825bac4f6988d7db53a0efc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compile 'org.jsoup:jsoup:1.10.2' | |
Document doc; | |
try { | |
doc = Jsoup.connect("https://jsoup.org/").followRedirects(true).get(); | |
// doc=Jsoup.parse(new File("/home/gufran/Desktop/JSoupStudy/StumbleUpon - StumbleUpon.html"),null); | |
// get title of the page | |
String title = doc.title(); | |
System.out.println("Title: " + title); | |
// get all links | |
// Elements links = doc.select("a[href]"); | |
// for (Element link : links) { | |
// // get the value from href attribute | |
// System.out.println("\nLink : " + link.attr("href")); | |
// System.out.println("Text : " + link.text()); | |
// } | |
Elements el = doc.select("div.col2"); | |
for (Element link : el) { | |
System.out.println("\nData : " + link); | |
System.out.println("Text : " + link.text()); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment