【发布时间】:2018-03-07 01:03:34
【问题描述】:
如何使用 BeautifulSoup 提取表格及其值?尝试遵循 bs4 文档,但在查找 class 或 th 值时遇到问题。我如何才能从整个 HTML 页面中显式获取 {underReplicatedBlocks} 值。
<div class="page-header"><h1><small>Decommissioning</small></h1></div>
<small>
<table class="table">
<thead>
<tr>
<th>Node</th>
<th>Last contact</th>
<th>Under replicated blocks</th>
<th>Blocks with no live replicas</th>
<th>Under Replicated Blocks <br/>In files under construction</th>
</tr>
</thead>
{#DecomNodes}
<tr>
<td>{name} ({xferaddr})</td>
<td>{lastContact}</td>
<td>{underReplicatedBlocks}</td>
<td>{decommissionOnlyReplicas}</td>
<td>{underReplicateInOpenFiles}</td>
</tr>
{/DecomNodes}
</table>
</small>
【问题讨论】:
标签: python python-2.7 beautifulsoup