I want to create an Auto-Login for Instagram.com with Python3. I informed myself that I have to use this to work with websites:
from selenium import webdriver
But on ALL tutorials I found they didn't had any problems with this, but I got an error message:
I browsed other questions and found this one that should solve my question too, but the Website and the Code they propose didn't solve my problem.
My full code so far:
from selenium import webdriver
from time import sleep
username = "username"
class InstaBot:
def __init__(self):
self.driver = webdriver.Chrome()
driver.get("https://instagram.com")
sleep(2)
login_field = 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)
InstaBot()
How can I fix this problem?
Edit: I now know that I have to install Selenium first with that code in command prompt:
pip3 install selenium
I did it and watched this Tutorial on YouTube and make it like him, but it just doesn't work. :(
It prints to console a very long Error message:
Traceback (most recent call last):
File "C:\Users\Jonas\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\Jonas\AppData\Local\Programs\Python\Python37-
32\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\Jonas\AppData\Local\Programs\Python\Python37-
32\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht
finden
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 16, in <module>
InstaBot()
File "main.py", line 8, in __init__
self.driver = webdriver.Chrome()
File "C:\Users\Jonas\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\Jonas\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver'
executable needs to be in PATH. Please see
https://sites.google.com/a/chromium.org/chromedriver/home