import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class HtmlParserExample {
public static void main(String[] args) {
try {
Document document = Jsoup.connect("https://example.com").get();
Element titleElement = document.select("h1").first();
String title = titleElement.text();
Elements links = document.select("a[href]");
for (Element link : links) {
String url = link.attr("href");
System.out.println(url);
}
String text = document.body().text();
System.out.println("Title: " + title);
System.out.println("Links: " + links.size());
System.out.println("Text: " + text);
} catch (Exception e) {
e.printStackTrace();
}
}
}