我正在尝试抓取 http://www.co.jefferson.co.us/ats/displaygeneral.do?sch=000104 并获取“所有者姓名”我所拥有的作品,但真的很丑而不是最好的我很确定,所以我正在寻找更好的方法。这是我所拥有的:
soup = BeautifulSoup(url_opener.open(url))
x = soup('table', text = re.compile("Owner Name"))
print 'And the owner is', x[0].parent.parent.parent.tr.nextSibling.nextSibling.next.next.next
相关的 HTML 是
<td valign="top">
<table border="1" cellpadding="1" cellspacing="0" align="right">
<tbody><tr class="tableheaders">
<td>Owner Name(s)</td>
</tr>
<tr>
<td>PILCHER DONALD L </td>
</tr>
</tbody></table>
</td>
哇,有很多关于beautifulsoup 的问题,我浏览了它们,但没有找到对我有帮助的答案,希望这不是重复的问题