HTMLParseer 获取标签内容 - html/css语言栏目:html.

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") + "***");
	}

返回顶部
跳到底部

Copyright 2011-2024 南京追名网络科技有限公司 苏ICP备2023031119号-6 乌徒帮 All Rights Reserved Powered by Z-BlogPHP Theme By open开发

请先 登录 再评论,若不是会员请先 注册