I have this textfile (links.txt) containing a list of url (100 urls). I can iterate the url list with the code below and the code currently works as expected. However, i want to randomly iterate only 36 of the urls in the list.
for i in range(20):
with open("links.txt") as in_file:
for url in in_file:
driver.get(url.strip())
try:
items1 = driver.find_elements_by_xpath("//div[@class='firms']//div")
sampled = random.sample(list(items1), 1)
for items in sampled:
items.click()
except:
continue
driver.find_element_by_xpath("//input[@value='houses']").click()