I made a bot for instagram using selenium. This bot should unfollow the accounts that i follow. It works just for the first 12 accounts! After that it stops! Why this happend? i tried to use try and except ! In except i ve made a scroll function but it didn t worked! Here s my code:
fBody = driver.find_element_by_xpath("//div[@class='isgrP']")
buttons = driver.find_elements_by_xpath("//button[contains(.,'Following')]")
for btn in range(len(buttons)):
try:
# Use the Java script to click on follow because after the scroll down the buttons will be un clickeable unless you go to it's location
driver.find_element_by_xpath("//button[contains(.,'Following')]").click()
#driver.execute_script("arguments[0].click();", btn)
sleep(2)
driver.find_element_by_xpath('//button[@class="aOOlW -Cab_ "]').click()
sleep(5)
except:
print("Eroare")
else:
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', fBody)