如何搜索包含<;sup>;在Python beautifulsoup find()调用中

如何搜索包含<;sup>;在Python beautifulsoup find()调用中,python,beautifulsoup,Python,Beautifulsoup,我正在使用Python中的beautifulsoup包搜索一个html文件。现在我想找到以下标签: <b>Particulate Matter (PM <sub>2.5</sub> ) [&#181;/m<sup>3</sup>] level in 2010 was </b> 这将返回我不想要的其他标记。此标签的相同单词为“颗粒物”、“2.5”、“2010年水平”您尝试过吗 soup.find(lambda tag

我正在使用Python中的beautifulsoup包搜索一个html文件。现在我想找到以下标签:

<b>Particulate Matter (PM <sub>2.5</sub> ) [&#181;/m<sup>3</sup>] level in 2010 was </b>
这将返回我不想要的其他标记。此标签的相同单词为“颗粒物”、“2.5”、“2010年水平”

您尝试过吗

soup.find(lambda tag: tag.name == 'b' and
          "Particulate Matter" in tag.text)

这确实有帮助。但我遇到了另一个问题,以你的方式,它也返回了PM10的标签。有没有像soup.find这样的方法(lambda标记:tag.name=='b'和tag.text中的“particle Matter”以及tag.sub中的“2.5”)
soup.find(lambda tag: tag.name == 'b' and
          "Particulate Matter" in tag.text)