0

I'm search in one html file using beautifulsoup package in Python. And now I wanna locate the following tag:

<b>Particulate Matter (PM <sub>2.5</sub> ) [&#181;/m<sup>3</sup>] level in 2010 was </b>

How could I do this?

I've tried to use

soup.find(text=re.compile("Particulate Matter"))

This returns other tags I don't want. The identical words for this tag is "Particulate Matter", "2.5", "level in 2010"

4

1 回答 1

0

你试过这个吗?

soup.find(lambda tag: tag.name == 'b' and
          "Particulate Matter" in tag.text)
于 2013-11-03T04:30:32.700 回答