4
嗨我想解析一个HTML表使用美丽的汤。 表看起来是这样的:美丽的汤和桌
<table width=100% border=1 cellpadding=0 cellspacing=0 bgcolor=#e0e0cc>
<tr>
<td width=12% height=1 align=center valign=middle bgcolor=#e0e0cc bordercolorlight=#000000 bordercolordark=white> <b><font face="Verdana" size=1><a href="http://www.dailystocks.com/" alt="DailyStocks.com" title="Home">Home</a></font></b></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
<tr class="odd"><td class="left"><a href="whatever">ABX</a></td><td class="left">Barrick Gold Corp.</td><td>55.95</td><td>55.18</td><td class="up">+0.70</td><td>11040601</td><td>70.28%</td><td><center> <a href="whatever" class="bcQLink"> Q </a> <a href="chart.asp?sym=ABX&code=XDAILY" class="bcQLink"> C </a> <a href="texpert.asp?sym=ABX&code=XDAILY" class="bcQLink"> O </a> </center></td></tr>
</table>
我想获得第二个表中的信息,到目前为止,我想这样的代码:
html = file("whatever.html")
soup = BeautifulSoup(html)
t = soup.find(id='table')
dat = [ map(str, row.findAll("td")) for row in t.findAll("tr") ]
这似乎没有工作,任何帮助将不胜感激, 谢谢