from selenium import webdriver
from time import sleep
class scrollDown:
def __init__(self, username, passWord):
self.driver = webdriver.Chrome()
self.driver.get("https://instagram.com")
self.username = username
self.passWord = passWord
sleep(2)
self.driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div[2]/div/label/input")\
.send_keys(username)
self.driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div[3]/div/label/input")\
.send_keys(passWord)
self.driver.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div[4]/button")\
.click()
sleep(5)
#REMOVE NOTIFICATIONS WINDOW
self.driver.find_element_by_xpath("/html/body/div[4]/div/div/div[3]/button[2]").click()
sleep(3)
print("Logged in")
for i in range(100):
self.driver.execute_script("window.scrollBy(0, 200)")
sleep(1)
print(str(i)+"%")
#ALTERNATIVE
headers = self.driver.find_elements_by_tag_name('header')
for users in headers:
pictureLocation = self.driver.find_element_by_class_name('O4GlU').get_attribute("href")
stringLocation = str(pictureLocation)
if "London" in stringLocation or "london" in stringLocation:
nameLink = users.find_elements_by_tag_name('a')
print(nameLink) Basically im trying to find out who is in town from my instagram fee but im struggling with the element selection
Can anyone help me pls?
