beautifulsoup table 中没有唯一标识符

beautifulsoup no unique identifier in table

我需要从没有唯一标识符(如唯一 class)的页面获取 table。该页面中有多个 table:

...
</table>
</font></td>
<td width="18"></td>
<td width="208">
<table>
    <TD><b>APPLE Smart History</b> Table</TD></TR>
    <tr><td><i><b>Date</b></i></td><td><i><b>Ratio</b></i></td></tr>
    <TR><TD>05/31/1994</TD><TD>3 over 1</TD></TR>
    <TR><TD>01/21/2004</TD><TD>2 over 1</TD></TR>
    <TR><TD>10/28/2008</TD><TD>5 over 4</TD></TR>
</table>
<table width="208" cellspacing="0" cellpadding="0" style="margin-bottom: 18px">
...

我需要 select table 第一列 <b>APPLE Smart History</b> Table,其中 APPLE 可能是随机字符串。所以 Fixed 是 Smart History</b> Table,永远不会改变。
其他已修复的是 table 中只有两列 DateRatio.
我需要获取此 table 中每一行的日期和比率。最好我可以遍历行:

for row in rows:
    pass

知道获取此数据的最佳 select 或 BeautifulSoup 是什么吗?

想法是通过检查其文本来找到 b 元素(我们将使用 function), then locate the first parent table 元素,然后找到其中的所有行:

b = soup.find("b", text=lambda x: x and x.endswith("Smart History"))
table = b.find_parent("table")
rows = table.find_all("tr")
for row in rows:
    # do smth with row