Python Forum

Full Version: Instagramlogin Error (Selenium)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried to make a python program that can (should) login into Instagram. Here's the code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

# Login Data Example001:

#[email protected]
#[email protected]
#subbot001ccom
#[email protected]



class InstagramBot:

    def __init__(self, username, password):
        self.username = username
        self.password = password
        self.driver = webdriver.Firefox()

    def closeBrowser(self):
        self.driver.close()

    def login(self):
        driver = self.driver
        driver.get("https://www.instagram.com/")
        time.sleep(2)
        login_button = driver.find_element_by_xpath("//a[@href='/accounts/login/']")
        login_button.click()
        time.sleep(2)
        user_name_elem = driver.find_element_by_xpath("//input[@name='username']")
        user_name_elem.clear()
        user_name_elem.send_keys(self.username)
        password_elem = driver.find_element_by_xpath("//input[@name='password']")
        password_elem.clear()
        password_elem.send_keys(self.password)
        password_elem.send_keys(Keys.RETURN)


example001 = InstagramBot("[email protected]", "[email protected]")
example001.login()
When i try to run it, it manages to open the front page of Instagram, but it produces the following error:
Error:
C:\Users\Julian\PycharmProjects\ib\venv\Scripts\python.exe C:/Users/Julian/PycharmProjects/ib/ibo1.py Traceback (most recent call last): File "C:/Users/Julian/PycharmProjects/ib/ibo1.py", line 41, in <module> example001.login() File "C:/Users/Julian/PycharmProjects/ib/ibo1.py", line 26, in login driver.get("https://www.instagram.com/") File "C:\Users\Julian\PycharmProjects\ib\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "C:\Users\Julian\PycharmProjects\ib\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\Julian\PycharmProjects\ib\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=dnsNotFound&u=https%3A//www.instagram.com/&c=UTF-8&f=regular&d=Die%20Verbindung%20mit%20dem%20Server%20www.instagram.com%20schlug%20fehl. Process finished with exit code 1
I recently tried to login into Instagram, with an test account using Pycharm and then that Error occured. I tried to fix it, but it still doesn't work like it should. The program is able to open the Instagram front page, but there it stops and that error occours. I followed this youtube Tutorial to make this: https://www.youtube.com/watch?v=BGU2X5lrz9M