如何用BeautifulSoup找到含有文字内容的标签?
print soup.find(‘h2’)
#>>
this is cool #12345678901
print soup.find(‘h2’, text=pattern)
#>> this is cool #12345678901
print soup.find(‘h2’, text=pattern).parent
#>>
this is cool #12345678901
print soup.find(‘h2’, text=pattern) == soup.find(‘h2’)
#>> False
print soup.find(‘h2’, text=pattern) == soup.find(‘h2’).text
#>> True
print soup.find(‘h2’, text=pattern).parent == soup.find(‘h2’)
#>> True