【问题标题】:search element with dynamic ID using java htmlunit使用 java htmlunit 搜索具有动态 ID 的元素
【发布时间】:2019-04-19 12:05:25
【问题描述】:

从一个网页,我想搜索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>

【问题讨论】:

  • 到目前为止你尝试了什么?

标签: java htmlunit htmlunit-driver


【解决方案1】:

首先: excample

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

及以后: excample

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-13
    • 2015-09-06
    • 2014-12-09
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    相关资源
    最近更新 更多