I am trying to get all the followers name
from this website https://www.quora.com/profile/Karan-Bansal-3/followers
Since the whole page is not loaded at once, I am using this everytime in a loop :
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
Now since I can't select all the element at once, I am trying to use indexing to find the element in the loop.
people = driver.find_element_by_xpath("//div[@class='pagedlist_item'][i]/*/div[@class='ObjectCard-header']/a[@class='user']")
Here as you can see, I am trying to give the indexing using [i]
which clearly doesn't work and in place of it, if I give [1] or any number it works well. So how can I select the element one by one.
Code snippet :
i=1
target = open(filename,'w')
driver.get('https://www.quora.com/profile/Karan-Bansal-3/followers')
while True:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
people = driver.find_element_by_xpath("//div[@class='pagedlist_item'][i]/*/div[@class='ObjectCard-header']/a[@class='user']")
target.write(people.text)
target.write("\n")
i = i+1