【发布时间】:2011-06-28 18:24:12
【问题描述】:
我正在使用 HTMLParser (org.htmlparser) 来解析 HTML。我已经用它来访问标签并获得像这样的标签属性:
NodeVisitor linkvisitor = new NodeVisitor() {
public void visitTag(Tag tag) {
if ("script".equalsIgnoreCase(name)) {
String srcValue = tag.getAttribute("src");
// do stuff
}
}
// How to get value instead of tag?
}
但是现在我需要获取标签之间的值,比如<script> 标签?
提前致谢。
【问题讨论】:
-
不是说htmlparser有什么问题,但是你考虑过JSoup吗?
-
@Andrew,感谢您的提示。刚到 JSoup 网站,看起来很有趣,我一定会研究一下。毕竟,我的代码设计非常松散耦合,我可以从解析器切换到解析器。再次感谢。
标签: java html html-parsing