我正在尝试使用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>
|
<a href="/admin/queues.jsp" title="Queues">Queues</a>
|
<a href="/admin/topics.jsp" title="Topics">Topics</a>
|
<a href="/admin/subscribers.jsp" title="Subscribers">Subscribers</a>
|
<a href="/admin/connections.jsp" title="Connections">Connections</a>
|
<a href="/admin/network.jsp" title="Network">Network</a>
|
<a href="/admin/scheduled.jsp" title="Scheduled">Scheduled</a>
|
<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:localhost
Version:5.13.3
ID:ID:TOOLCONTROLPJX526-524666-65544585445-2:3
Uptime:7 days 13 hours
Store percent used:19
Memory percent used:0
Temp percent used:0
如何实现?我想知道要在HTLM单元中使用哪些方法来实现这一目标。
相关分类