I am trying to scrape some data, with Simple HTML DOM Parser, from a page that has the following structure:
<div class='image'>
<img class='a' src='1.jpg'>
</div>
<div class='data'>
lorem ipsum 1
</div>
<div class='data'>
lorem ipsum 2
</div>
<div class='data'>
lorem ipsum 3
</div>
<div class='image'>
<img class='a' src='2.jpg'>
</div>
<div class='data'>
lorem ipsum 4
</div>
<div class='image'>
<img class='a' src='3.jpg'>
</div>
<div class='data'>
lorem ipsum 5
</div>
<div class='data'>
lorem ipsum 6
</div>
I can easily get all the data. My problem is that I cannot associate the images with the data divs underneath. (Divs are not nested)
I need to associate image 1.jpg with data 1, 2 & 3 image 2.jpg with data 4 image 3.jpg with data 5,6
The number of divs between the image divs are random
Is there any way to count the number of divs between two divs with class image even if they are not nested.
I apologize if the question seems complicated, but I assure you the question is very simple if you look at it carefully.