Questions says it all but in a few line..
I’ve got HTML page which looks like this
...
<div class="line-up" .. > .. </>
<div class="line-down" ..> .. </>
<div class="line-down" ..> .. </>
<div class="line-down" ..> .. </>
...
<div class="line-up" ..> .. </>
<div class="line-down" ..> .. </>
I want to be able to iterate through each <div class="line-down"> belonging to one <div class="line-up">
and go on with the next <div class="line-down"..> .
I can already iterate through each <div class="line-up"> with :
for first_line in soup.findAll("div",class_="line-up"):
But I just can’t find what to do to iterate with the next div and stopping at a point.
Any ideas?
first, get all div tags–
findAll("div"), dont worry about the class. Then, iterate through your results, and ifclass=="line-down", break.