![]() |
Webelement scroll - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Webelement scroll (/thread-25047.html) |
Webelement scroll - rove76 - Mar-17-2020 Hey so i use selenium and i would like to scroll insie an element but can't find the way to do it. this is what i tried so far: def findfollowers (self): driver = self.driver driver.get("https://www.instagram.com/explore/tags/doglover/") time.sleep(3) firstpic= driver.find_elements_by_xpath('/html/body/div[1]/section[1]/main[1]/article[1]/div[1]/div[1]/div[1]/div[1]/div[1]/a') pichref = [elem.get_attribute('href')for elem in firstpic] driver.get(pichref[0]) time.sleep(3) likers_button = driver.find_element_by_xpath('/html/body/div/section/main/div/div/article/div[2]/section[2]/div/div/button') likers_button.click() time.sleep(3) element = driver.find_element_by_xpath("/html/body/div[4]/div/div[2]/div/div") #driver.execute("document.querySelector('/html/body/div[5]/div/div[2]').scroll.Top=500") #for i in range(1, 3): #element = driver.find_element_by_xpath('/html/body/div[4]/div/div[2]/div/div' driver.execute("document.element.scroll.Top=500") RE: Webelement scroll - rove76 - Mar-17-2020 Execption : 'document.element.scroll.Top=500' from selenium import webdriver from selenium.webdriver.common.keys import Keys import time class instagrambot : def __init__(self, username,password): self.username = username self.password = password self.driver = webdriver.Chrome("L:\webdrivers\chromedriver.exe") def closeBrowser(self): self.closeBrowser() def login (self): driver = self.driver driver.get("https://www.instagram.com") time.sleep(3) login_button = driver.find_element_by_xpath("//input[@name = 'username']") password_button = driver.find_element_by_xpath("//input[@name = 'password']") login_button.clear() login_button.send_keys(self.username) password_button.clear() password_button.send_keys(self.password) password_button.send_keys(Keys.RETURN) time.sleep(3) no_button =driver.find_element_by_xpath('/html/body/div[4]/div/div/div[3]/button[2]') no_button.click() def findfollowers (self): driver = self.driver driver.get("https://www.instagram.com/explore/tags/doglover/") time.sleep(3) firstpic= driver.find_elements_by_xpath('/html/body/div[1]/section[1]/main[1]/article[1]/div[1]/div[1]/div[1]/div[1]/div[1]/a') pichref = [elem.get_attribute('href')for elem in firstpic] driver.get(pichref[0]) time.sleep(3) likers_button = driver.find_element_by_xpath('/html/body/div/section/main/div/div/article/div[2]/section[2]/div/div/button') likers_button.click() time.sleep(3) element = driver.find_element_by_xpath("/html/body/div[4]/div/div[2]/div/div") #driver.execute("document.querySelector('/html/body/div[5]/div/div[2]').scroll.Top=500") #for i in range(1, 3): #element = driver.find_element_by_xpath('/html/body/div[4]/div/div[2]/div/div' driver.execute("document.element.scroll.Top=500") Program= instagrambot("Username","Password12345") Program.login() Program.findfollowers() |