为了账号安全,请及时绑定邮箱和手机立即绑定

使用HTMLUNIT从标签之间的HTML页面提取数据

使用HTMLUNIT从标签之间的HTML页面提取数据

HUWWW 2021-04-09 14:15:26
我正在尝试使用HTML单元从网页中提取数据。通过将HtmlPage转换为文本,然后使用该HTML页面中的正则表达式提取数据,我已经实现了这一点。我还实现了使用HTML中的class属性从HTML表中提取数据。我想再次对所有提取再次完全使用HtmlUnit,以学习使用正则表达式所做的相同要求。无法获取如何以键值对的形式提取标记内的数据。这是样本HTML数据<div class="top_red_bar">    <div id="site-breadcrumbs">        <a href="/admin/index.jsp" title="Home">Home</a>        &#124;        <a href="/admin/queues.jsp" title="Queues">Queues</a>        &#124;        <a href="/admin/topics.jsp" title="Topics">Topics</a>        &#124;        <a href="/admin/subscribers.jsp" title="Subscribers">Subscribers</a>        &#124;        <a href="/admin/connections.jsp" title="Connections">Connections</a>        &#124;        <a href="/admin/network.jsp" title="Network">Network</a>        &#124;         <a href="/admin/scheduled.jsp" title="Scheduled">Scheduled</a>        &#124;        <a href="/admin/send.jsp"           title="Send">Send</a>    </div>    <div id="site-quicklinks"><P>        <a href="http://activemq.apache.org/support.html"           title="Get help and support using Apache ActiveMQ">Support</a></p>    </div></div><table border="0"><tbody>    <tr>        <td valign="top" width="100%" style="overflow:hidden;">            <div class="body-content"><h2>Welcome!</h2><p>Welcome to the Apache ActiveMQ Console of <b>localhost</b> (ID:TOOLCONTROLPJX526-524666-65544585445-2:3)</p><p>You can find more information about Apache ActiveMQ on the <a href="http://activemq.apache.org/">Apache ActiveMQ Site</a></p><h2>Broker</h2><table>    <tr>        <td>Name</td>        <td><b>localhost</b></td>    </tr>    <tr>        <td>Version</td>        <td><b>5.13.3</b></td>    </tr>    <tr>        <td>ID</td>        <td><b>ID:TOOLCONTROLPJX526-524666-65544585445-2:3</b></td>    </tr>    <tr>        <td>Uptime</td>        <td><b>17 days 13 hours</b></td>    </tr>我想提取表标签之间的数据。预期产量Name:localhostVersion:5.13.3ID:ID:TOOLCONTROLPJX526-524666-65544585445-2:3Uptime:7 days 13 hoursStore percent used:19Memory percent used:0Temp percent used:0如何实现?我想知道要在HTLM单元中使用哪些方法来实现这一目标。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 334 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信