【发布时间】:2016-08-26 05:34:08
【问题描述】:
<tr bgcolor="#FFFFFF">
<td class="tablecontent" scope="row" rowspan="1">
<a href="http://netprofile-us2/netprofile/npIndex.do?cpyKey=80823">ZURICH AMERICAN INSURANCE COMPANY</a>
</td>
<td class="tablecontent" scope="row" rowspan="1">
FARMERS GROUP INC (14523)
</td>
<td class="tablecontent" scope="row">
znaf
</td>
<td class="tablecontent" scope="row">
anhm
</td>
</tr>
我有一个包含多个 tr 标记的 HTML 文档。我想从第一个td 中提取href 链接,并从每个tr 标记下的第三个td 标记中提取数据。如何实现?
【问题讨论】:
-
您是要获取具有特定属性的元素还是每个第 n 个元素?
-
我想遍历所有 tr 标签并在同一行中只打印
标签的元素,直到我得到 标签。
标签: python python-2.7 beautifulsoup