Parser parser = Parser.createParser(content,"utf-8") ;
HtmlPage nowpage = new HtmlPage(parser);
try
{
parser.visitAllNodesWith(nowpage);
}
catch (ParserException e1) {
e1 = null;
}
NodeList nodelist = nowpage.getBody();
System.out.println(nodelist) ;
NodeFilter filter = new TagNameFilter("Meta");
nodelist = nodelist.extractAllNodesThatMatch(filter, true);
System.out.println(nodelist.size() + "***");
for (int i = 0; i < nodelist.size(); i++)
{
LinkTag link=(LinkTag) nodelist.elementAt(i);
System.out.println(link.getAttribute("keywords") + "***");
}
HTMLParseer 获取标签内容
最新推荐文章于 2024-09-04 10:53:03 发布