1
给出的例子HTML字符串找不到标签和正则表达式BeautifulSoup
<table>
<tr>
<td class="td" height="25">Upstream Power</td>
<td class="td">25.2 dBmV</td>
<td class="td">49.2 dBmV</td>
</tr>
</table>
我可以用查找文本:
soup.find_all(text=re.compile("Power"))
但要找到整个标签没有找到任何东西。我错过了什么?
soup.find_all("td",text=re.compile("Power"))
是soup.find_all(文= re.compile(”电源'))也适用于我,但为什么不soup.find_all(“td”,text = re.compile(“Power”))。我需要这样的东西,因为我想从这一点开始遍历树。 – CptanPanic 2012-03-22 19:24:10
@CptanPanic:啊,我错过了。我用更好的方式编辑答案,以获得你想要的元素。 – bernie 2012-03-22 19:38:37