I am trying to scrape a webpage that has multiple div elements. Each suppose to have a fixed number of other children. However, sometimes, due to not entering an input by the admin,one of those children's divs is missed. Here 2 samples to give you a better idea:
//example 1
<div class = "row Book_Details">
<div class="class="col-md-4 col-lg-4" style="display:flex"></div>
<div class="class="col-md-4 col-lg-4" style="display:flex"></div>
</div>
//sample 2:
<div class = "row Book_Details">
<div class="class="col-md-4 col-lg-4" style="display:flex"></div>
<div class="class="col-md-4 col-lg-4" style="display:flex"></div>
<div class="class="col-md-4 col-lg-4" style="display:flex"></div>
</div>
Is there any way to exclude the parent based on a threshold when it missed one of the children's divs? Let's say, I will find all of them and check if one of them has less number of children so I exclude it! Or may be filling the text of the missed one by a string value like NA
I am using Selenium and driver.find_elements(('xpath',...). I tried to count how many children are under the parent DIV and then add some If statements to exclude that found one.
Here is my attempted code:
for match in driver.find_elements('xpath','//div[@class="col-md-6 col-lg-6 col-xs-12"]//div[@class="row Book_Details"]'):
while len(match.find_elements('xpath','.//*'))==17:
ExperienceLevel= match.find_elements('xpath','//div[@class="col-md-4 col-lg-4"]')
Any guidance is much appreciated here!
Maybe this layout screenshot helps tp understand the challenge:
