I am currently attempting to scrape a webpage for a small project. However, when attempting to select everything between two headings I've run into a problem. Here is an example of one of the headings I am trying to select:
<h2><a class="autolink" href="/compendium/dnd5e/Social%20Interaction#h-Long%20Rest">Long Rest</a></h2>
Found in: https://roll20.net/compendium/dnd5e/Rules:Resting/#h-Resting
And here is the code I have so far:
els = soup.select("h2:has(a:contains('Short Rest')) ~ *:has(~ h2:has(a:contains('Long Rest')))")
However, using this returns a list of all the tags used and their, not the text as I thought. The desired output would be all the HTML between h2 'Short Rest' and h2 'Long Rest', so essentially the text describing a short rest.
The reason I am not using a simpler tag.next_sibling method is that there is a lot of untagged text on this webpage, which that method skips over.
Any help would be greatly appreciated, I've been stuck on this for a while now.