I am trying to loop through a piece of info for a x amount of times, but I can't seem to make it work with range() or isslice. I want to be able to say that the code within the loop are only looped x amount of times.
The loop I would like to loop trough x amount of times:
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
x = soup.find("div", class_="object-list-items-container")
for child in x.findChildren("section", recursive=False):
if "U heeft gereageerd" in child.text:
continue
else:
house_id = child.find("div", {'class': 'ng-scope'}).get("id")
driver.find_element_by_id(house_id).click()
I've read quite some stack overflow questions but i'm probably not experienced enough to implement it for my situation. I have tried a couple of things, but nothing worked so far.
I've tried the following:
("reacties" is the variable for the x amount of times it needs to loop)
for i in range(reacties):
for child in x.findChildren("section", recursive=False):
if "U heeft gereageerd" in child.text:
continue
else:
...........
and:
for i in range(reacties):
child= x.findChildren("section", recursive=False)
if "U heeft gereageerd" in child.text:
continue
else:
...............