import net.htmlparser.jericho.*;
public class JerichoParser {
public static void main(String[] args) throws Exception {
String html = "<html><head><title>Example</title></head><body><h1>Hello, World!</h1></body></html>";
Source source = new Source(html);
Element h1Element = source.getFirstElement("h1");
String text = h1Element.getTextExtractor().toString();
System.out.println(text);
}
}
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
public class JsoupParser {
public static void main(String[] args) throws Exception {
String html = "<html><head><title>Example</title></head><body><h1>Hello, World!</h1></body></html>";
Document document = Jsoup.parse(html);
Element h1Element = document.select("h1").first();
String text = h1Element.text();
System.out.println(text);
}
}