vendredi 14 mai 2021

How to scroll down every nth element

I want scroll down every 8th users & grab this on my list :

My code :

fBody  = driver.find_element_by_xpath("//div[@class='isgrP']")
scroll = 0

  def every_8th(range(100)) # many user i want grab
    for i in range(7): # loop serve to add users
        val = elems[i].get_attribute('innerHTML')
        followers.append(val)
        print(followers) 
        if followers < [::8] : # every 8th users, (i think it not that way)
                browser.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', fBody)
                sleep(2)
                
        continue 

I know my code it a few ridiculous (im beginner on python & selenium), i try my best for understanding python, i don't know use continue but i found this :

enter image description here

Aucun commentaire:

Enregistrer un commentaire