Parse The Inner Html Tags Using JSoup February 20, 2023 Post a Comment I want to find the important links in a site using Jsoup library. So for this suppose we have following code: This is important Solution 1: You can do it this way: File input = new File("/tmp/input.html"); Document doc = Jsoup.parse(input, "UTF-8", "http://example.com/"); Elements headlinesCat1 = doc.getElementsByTag("h1"); for (Element headline : headlinesCat1) { Elements importantLinks = headline.getElementsByTag("a"); for (Element link : importantLinks) { String linkHref = link.attr("href"); String linkText = link.text(); System.out.println(linkHref); } } Copy Taken from the JSoup Cookbook. Share You may like these postsStill Have Space After Margin, Padding, Border All Zero?Html Email Just Shows As CodePrint In Separate Page Javascript?Changing Font Color Of Link Text Post a Comment for "Parse The Inner Html Tags Using JSoup"
Post a Comment for "Parse The Inner Html Tags Using JSoup"