import net.htmlparser.jericho.*; public class HTMLParserExample { public static void main(String[] args) { try { String html = "<html><body><h1>Hello, Jericho HTML Dev!</h1></body></html>"; Source source = new Source(html); Element h1Element = source.getFirstElement(HTMLElementName.H1); if (h1Element != null) { String text = h1Element.getTextExtractor().toString(); System.out.println("Extracted text: " + text); } else { System.out.println("No h1 element found."); } } catch (Exception e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文