【发布时间】:2017-10-31 18:49:16
【问题描述】:
我有一个 html 页面,我想从中提取具有类属性 bold 的 td 元素。而是弹出其他 td 元素,例如 dark bold
当我在 BeautifulSoup 中使用 findAll 方法时,
scores= soup.findAll(lambda tag: tag.name == 'td', { "class" : "bold"})
我得到了所有这些元素
<td class="dark bold">
<span class="hide-for-tablet">Sebastian</span>
<span class="hide-for-mobile">Vettel</span>
<span class="uppercase hide-for-desktop">VET</span>
</td>
<td class="bold hide-for-mobile">78</td>
<td class="dark bold">1:44:44.340</td>
<td class="bold">25</td>
我真正想要的是
<td class="bold">25</td>
如何缩小结果范围?
【问题讨论】:
标签: html python-2.7 class beautifulsoup findall