【发布时间】:2015-11-07 00:46:57
【问题描述】:
我想用美丽的汤从标签之间提取文本。到目前为止,我有:
def table_to_text(html):
from bs4 import BeautifulSoup
soup = BeautifulSoup(html)
trs = soup.findAll('tr')
for tr in trs:
print 'row '
print tr.findAll(['td','th']).text
这给了我这样的输出:
row
[<td> AAA </td>, <td>Chi</td>, <td></td>, <td class="center"><span class="blue">1353</span>/<span class="red">23</span></td>]/n
我想让输出看起来像:
[ AAA , Chi, , 1353, 23]
我该怎么做?
【问题讨论】:
标签: python html beautifulsoup