I write a script for instagram. And i need a method which returns me a list of followers. My followers is not visible(only 10) and i must to scroll down the page. I am using selenium webdriver and python to automate this process. But unfortunately it doesn't scroll down.Here is my code
def get_followers(self):
try:
driver.find_elements_by_css_selector('a._t98z6')[0].click()
except Exception as e:
print("Sorry, i don't have access to your followers: {0}".format(e))
else:
followers = []
while True:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
try:
WebDriverWait(driver, 20).until(lambda x: x.find_element_by_css_selector("li._6e4x5"))
except:
break
followers = driver.find_elements_by_css_selector("a._2g7d5.notranslate._o5iw8")
return followers
Any solutions would be much appreciated. Thanks.