import net.htmlparser.jericho.*; public static void parseHtmlDocument() throws IOException { String sourceUrlString = "index.html"; Source source = new Source(new URL(sourceUrlString)); String content = source.toString(); System.out.println(content); } public static void parseHtmlDocument() throws IOException { String sourceUrlString = "index.html"; Source source = new Source(new URL(sourceUrlString)); List<Element> divElements = source.getAllElements("div"); for (Element divElement : divElements) { System.out.println(divElement.getAttributeValue("id")); } } public static void main(String[] args) { try { parseHtmlDocument(); } catch (IOException e) { e.printStackTrace(); } } import net.htmlparser.jericho.*; import java.io.IOException; import java.net.URL; import java.util.List; public class HtmlParser { public static void parseHtmlDocument() throws IOException { String sourceUrlString = "index.html"; Source source = new Source(new URL(sourceUrlString)); List<Element> divElements = source.getAllElements("div"); for (Element divElement : divElements) { System.out.println(divElement.getAttributeValue("id")); } } public static void main(String[] args) { try { parseHtmlDocument(); } catch (IOException e) { e.printStackTrace(); } } }


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