Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selenium big struggle
#1
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?
Reply


Messages In This Thread
Selenium big struggle - by Troop - Apr-24-2020, 07:43 PM
RE: Selenium big struggle - by Jeff900 - Apr-24-2020, 07:53 PM
RE: Selenium big struggle - by Troop - Apr-25-2020, 10:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Class Struggle: Connecting a Method to an Outside Variable vulpesVelox 7 4,549 Jan-27-2018, 10:11 PM
Last Post: vulpesVelox
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,681 Nov-03-2017, 08:41 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020