<!-- https://mvnrepository.com/artifact/org.jodd/jodd-all -->
<dependency>
<groupId>org.jodd</groupId>
<artifactId>jodd-all</artifactId>
<version>5.1.0</version>
</dependency>
Jerry doc = Jerry.jerry(html);
// 查找<p>标签
doc.find("p")
// 遍历dom对象
doc.each(new JerryFunction() {
int p = 20;
@Override
public Boolean onNode(Jerry jerry, int index) {
if ("p".equals(jerry.get(0).getNodeName()) && jerry.parent().get(0).getNodeName() == null) {
p--;
sb.append(jerry.htmlAll(true));
}
return true;
}
});
参考官方文档:https://jodd.org/jerry/jerry-examples.html