【发布时间】:2016-05-12 10:20:20
【问题描述】:
是否有简化 HTML 表格的好方法(例如使用 BeautifulSoup)。我正在使用请求来获取表格并使用 BeautifulSoup 提取表格,但我需要表格来自:
<table>
<thead></thead>
<tbody>
<tr>
<td><a id="bar">Some text<br></br><span class="foobar">foo </span><small class="foo">bar!</small></a></td>
</tr>
</tbody>
</table>
到:
<table>
<thead></thead>
<tbody>
<tr>
<td>Some text\nfoo bar!</td>
</tr>
</tbody>
</table>
通过一种简单的方式,那么我在考虑不必去每个标签并使用 soup.get_text()。
【问题讨论】:
-
为什么
<br><br/>只产生一个\n? -
应该是
,抱歉。我知道它可能是
。但这些是我正在使用的数据。
标签: python html beautifulsoup python-requests