public static void extractText(String inputHtml) throws Exception{
Parser parser = Parser.createParser(inputHtml, "GBK");
//遍历所有的节点
NodeList nodeList = parser.extractAllNodesThatMatch(new NodeFilter(){
public boolean accept(Node node) {
return true;
}}); Node[] nodes = nodeList.toNodeArray();
for (int i = 0; i < nodes.length; i++)
{
String line = nodes[i].getText();
System.out.println(line);
} }
Parser parser = Parser.createParser(inputHtml, "GBK");
//遍历所有的节点
NodeList nodeList = parser.extractAllNodesThatMatch(new NodeFilter(){
public boolean accept(Node node) {
return true;
}}); Node[] nodes = nodeList.toNodeArray();
for (int i = 0; i < nodes.length; i++)
{
String line = nodes[i].getText();
System.out.println(line);
} }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货