<dependency>
<groupId>net.htmlparser.jericho</groupId>
<artifactId>jericho-html</artifactId>
<version>3.4</version>
</dependency>
import net.htmlparser.jericho.*;
public class HtmlParserExample {
public static void main(String[] args) {
try {
Source source = new Source(new URL("http://example.com"));
String title = source.getFirstElement(HTMLElementName.TITLE).getTextExtractor().toString();
List<Element> paragraphs = source.getAllElements(HTMLElementName.P);
System.out.println("Title: " + title);
System.out.println("Paragraphs:");
for (Element paragraph : paragraphs) {
System.out.println(paragraph.getTextExtractor().toString());
System.out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}