- File input = new File("/tmp/input.html");
- Document doc = Jsoup.parse(input, "UTF-8", "<a href="http://www.CideSnippet.cn/">http://www.CideSnippet.cn/");
- Element content = doc.getElementById("content");
- Elements links = content.getElementsByTag("a");
- for (Element link : links) {
- String linkHref = link.attr("href");
- String linkText = link.text();
- }
- //该片段来自于http://www.codesnippet.cn/detail/240120131916.html
来源: http://www.codesnippet.cn/detail/240120131916.html