Вы можете использовать find_next , чтобы получить следующий тег.
from bs4 import BeautifulSoup
import requests
res=requests.get("https://www.w3schools.com/python/ref_string_split.asp")
soup=BeautifulSoup(res.text,"html5lib")
h2=soup.find("h2", string="Definition and Usage")
p_after_h2=h2.find_next("p")
p_text_after_h2=p_after_h2.text.replace("\n","")
print(p_after_h2)
print(p_text_after_h2)
выход
<p>The <code class="w3-codespan">split()</code> method splits a string into a
list.</p>
The split() method splits a string into a list.
HTML-код страницы
...
<div class="w3-example">
<h3>Example</h3>
<p>Split a string into a list where each word is a list item:</p>
<div class="w3-code notranslate pythonHigh">
txt = "welcome to the jungle"<br><br>x = txt.split()<br><br>
print(x)</div>
<a target="_blank" class="w3-btn w3-margin-bottom" href="showpython.asp?filename=demo_ref_string_split">Run example »</a>
</div>
<hr>
<h2>Definition and Usage</h2>
<p>The <code class="w3-codespan">split()</code> method splits a string into a
list.</p>
<p>You can specify the separator, default separator is any whitespace.</p>
<div class="w3-panel w3-note">
<p><strong>Note:</strong> When max is specified, the list will contain the
specified number of elements <em>plus one</em>.</p>
</div>
<hr>
<h2>Syntax</h2>
<div class="w3-code w3-border notranslate">
<div>
<em>string</em>.split(<em>separator, max</em>)
</div>
</div>
...
Это наш ответный текст. Использование
h2=soup.find("h2", string="Definition and Usage")
мы получаем тег h2 с "Definition and Usage" внутри него. Затем мы находим следующий p после этого тега h2, используя
p_after_h2=h2.find_next("p")
Наконец мы используем
p_text_after_h2=p_after_h2.text.replace("\n","")
получить текст в теге p
после удаления перевода строки.