使用Java htmlunit的具有动态ID的搜索元素

时间:2019-04-19 12:05:25

标签: java htmlunit htmlunit-driver

我想从网页中搜索所有ID为'Tomcat_''_released'结尾的h3

<h3 id="Tomcat_9.0.19_Released">
  <span class="pull-right">
    2019-04-13
  </span>
   Tomcat 9.0.19 Released
</h3>

1 个答案:

答案 0 :(得分:0)

第一: excample

DomNodeList<DomElement> ss = page.getElementsByTagName("h3");

及更高版本: excample

String value = temp.getAttribute("id");

if(value.startsWith("Tomcat_")&value.endsWith("_released")){
System.out.println(value);
} 
相关问题