码迷,mamicode.com
首页 > Web开发 > 详细

HTMLParseer 获取标签内容

时间:2015-02-07 18:58:38      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:

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 获取标签内容

标签:

原文地址:http://blog.csdn.net/honglei_zh/article/details/43604997

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!