I couldn't find an answer to my specific question on SO so here it goes. Suppose I have an HTML that looks something like (sorry if it looks a bit stupid, I just wanted to make a very minimal example that captures my problem):
html1 = """<html>
<head></head>
<body>
<p>Hello World!</p>
<a href='whatevs.com'>whatevs</a>
<p>Howdy!</p>
<a href='well.com'>well</a>
<div><span>haha</span><a href='haha.com'>haha</a></div>
<a href='goodbye.com'>Goodbye!</a>
</body>
</html>"""
I want to extract all the links in here that come after <p>Howdy!</p>.
So I tried,
howdy = BeautifulSoup(html1).find('p', text='Howdy!')
but both howdy.find_next_siblings('a') and howdy.find_next('a') return something a bit different from what I want.
Desired output:
[<a href="well.com">well</a>,
<a href="haha.com">haha</a>,
<a href="goodbye.com">Goodbye!</a>]
(Well actually, it's ['well','haha','Goodbye!'] but I think I can get this from above.)
Ideally, I want something like howdy.find_all('a').
Sorry if it's too basic a question but I'd really appreciate if anyone can direct to the right direction. Thanks!