Q:

Beautifulsoup tag - find_all successful but find failed

I am having a problem where soup.find_all for a specific tag h2 is successful but soup.find specifying the text fails.
I need to find the h2 tags with various text such as Introduction, Results etc as shown in the attached picture.
Can somebody please advise? Thank you.
print(soup.find_all('h2'))
[<h2 class="Heading">Abstract</h2>, 
<h2 class="Heading" data-role="collapsible-handle" tabindex="-1">Introduction<span class="section-icon"></span></h2>, 
<h2 class="Heading" data-role="collapsible-handle" tabindex="-1">Patients and methods<span class="section-icon"></span></h2>, 
<h2 class="Heading" data-role="collapsible-handle" tabindex="-1">Results<span class="section-icon"></span></h2>, 
<h2 class="Heading" data-role="collapsible-handle" tabindex="-1">Discussion<span class="section-icon"></span></h2>, 
<h2 class="Heading" data-role="collapsible-handle" id="copyrightInformation" tabindex="-1">Copyright information<span class="section-icon"></span></h2>, 
<h2 class="Heading" data-role="collapsible-handle" id="aboutarticle" tabindex="-1">About this article<span class="section-icon"></span></h2>, 
<h2 class="u-isVisuallyHidden">Article actions</h2>, <h2 class="u-h4 u-jsIsVisuallyHidden">Article contents</h2>, 
<h2 class="u-isVisuallyHidden">Cookies</h2>]

print(soup.find('h2', text='Introduction'))
None

A:

Try this:
soup.find(lambda el: el.name == "h2" and "Introduction" in el.text)

