我有以下 html 代码,我使用漂亮的汤来提取信息。我想获得例如关系状态:关系
<table class="box-content-list" cellspacing="0">
<tbody>
<tr class="first">
<td>
<strong>
Relationship status:
</strong>
Relationship
</td>
</tr>
<tr class="alt">
<td>
<strong>
Living:
</strong>
With partner
</td>
</tr>
我创建了以下代码:
xs = [x for x in soup.findAll('table', attrs = {'class':'box-content-list'})]
for x in xs:
#print x
sx = [s for s in x.findAll('tr',attrs={'class':'first'})]
for s in sx:
td_tabs = [td for td in s.findAll('td')]
for td in td_tabs:
title = td.findNext('strong')
#print str(td)
status = td.findNextSibling()
print title.string
print status
但我得到的结果是关系状态:打印状态是打印无。我做错了什么?