import net.htmlparser.jericho.*;
Source source = new Source(new File("path/to/your/html/file.html"));
public class HTMLParserDemo {
public static void main(String[] args) {
try {
Source source = new Source(new File("path/to/your/html/file.html"));
List<Element> linkElements = source.getAllElements("a");
for (Element element : linkElements) {
String link = element.getAttributeValue("href");
String text = element.getTextExtractor().toString();
System.out.println("Link: " + link);
System.out.println("Text: " + text);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}