I am trying to parse an html page with the given format:
<img class="outer" id="first" /> <div class="content" .../> <div class="content" .../> <div class="content" /> <img class="outer" id="second" /> <div class="content" .../> <div class="content" .../> <img class="outer" id="third" /> <div class="content" .../> <div class="content" .../>
When repeating div tags, I want to find out if the current div tag is under the img tag with the identifier "first", "second" or "third". Is there any way to do this? I have a list of img blocks and div blocks:
img_blocks = soup.find_all('img', attrs={'class':'outer'}) div_Blocks = soup.find_all('div', attrs={'class':'content'})
source share