I'm getting an error when trying to reach my Instagram followers in Selenium

Joined
Jan 9, 2023
Messages
2
Reaction score
0
Python:
``
from instagramUserInfo import username,password
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time

class Instagram:
    def init(self, username, password):
        self.browser = webdriver.Chrome()
        self.username = username
        self.password = password
    def signIn(self):
        self.browser.get("https://www.instagram.com/accounts/login/")
        time.sleep(2)
        usernameInput = self.browser.find_element(By.XPATH, "//*[@id='loginForm']/div/div[1]/div/label/input")
        passwordInput = self.browser.find_element(By.XPATH, "//*[@id='loginForm']/div/div[2]/div/label/input")

        usernameInput.send_keys(self.username)
        passwordInput.send_keys(self.password)
        passwordInput.send_keys(Keys.ENTER)
        time.sleep(2)

    def getFollowers(self):
        self.browser.get(f"https://www.instagram.com/{self.username}")
        time.sleep(3)
        followersLink = self.browser.find_element(By.XPATH, "//*[@id='mount_0_0_fu']/div/div/div/div[1]/div/div/div/div[1]/div[1]/div[2]/section/main/div/ul/li[2]/a/div")
        followersLink.click()

instgrm = Instagram(username, password)
instgrm.signIn()
instgrm.getFollowers() ``

I want to reach my instagram followers.

Error from:

DevTools listening on ws://127.0.0.1:52672/devtools/browser/48d6ad97-afc1-4f78-80e5-e400a6727cb8
[17604:25192:0111/144354.050:ERROR:device_event_log_impl.cc(215)] [14:43:54.050] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter failed.
Traceback (most recent call last):
File "C:\Users\oguzc\Desktop\Çalışmalarım\Yazılım\90-instagram.py", line 33, in <module>
instgrm.getFollowers()
File "C:\Users\oguzc\Desktop\Çalışmalarım\Yazılım\90-instagram.py", line 27, in getFollowers
followersLink = self.browser.find_element(By.XPATH, "//*[@id='mount_0_0_vv']/div/div/div/div[1]/div/div/div/div[1]/div[1]/div[2]/section/main/div/ul/li[2]/a")
File "C:\Users\oguzc\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 861, in find_element
return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
File "C:\Users\oguzc\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 444, in execute
self.error_handler.check_response(response)
File "C:\Users\oguzc\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 249, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='mount_0_0_vv']/div/div/div/div[1]/div/div/div/div[1]/div[1]/div[2]/section/main/div/ul/li[2]/a"}
(Session info: chrome=108.0.5359.125)
Stacktrace:
Backtrace:
(No symbol) [0x0035F243]
(No symbol) [0x002E7FD1]
(No symbol) [0x001DD04D]
(No symbol) [0x0020C0B0]
(No symbol) [0x0020C22B]
(No symbol) [0x0023E612]
(No symbol) [0x002285D4]
(No symbol) [0x0023C9EB]
(No symbol) [0x00228386]
(No symbol) [0x0020163C]
(No symbol) [0x0020269D]
GetHandleVerifier [0x005F9A22+2655074]
GetHandleVerifier [0x005ECA24+2601828]
GetHandleVerifier [0x00408C0A+619850]
GetHandleVerifier [0x00407830+614768]
(No symbol) [0x002F05FC]
(No symbol) [0x002F5968]
(No symbol) [0x002F5A55]
(No symbol) [0x0030051B]
BaseThreadInitThunk [0x768C7D69+25]
RtlInitializeExceptionChain [0x7794BB9B+107]
RtlClearBits [0x7794BB1F+191]
 
Joined
Jan 30, 2023
Messages
107
Reaction score
13
The error message is saying that the element you are trying to locate with the XPATH "//*[@id='mount_0_0_vv']/div/div/div/div[1]/div/div/div/div[1]/div[1]/div[2]/section/main/div/ul/li[2]/a" cannot be found. This could be because the XPATH is not correct, or because Instagram has changed their page structure and your XPATH needs to be updated. To fix this, try using a different selector method (e.g. CSS selector) or try using a tool like the "Inspect Element" feature in Google Chrome to get the updated XPATH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,928
Messages
2,570,068
Members
46,513
Latest member
JacklynMcC

Latest Threads

Top