Open misterpeople opened 2 years ago
Im trying to do chrome Automatication like logging in a website
@misterpeople I posted this on another issue as well. Since this here is the same error and problem as the other one, you should take a look at the fix I found. Just click the link below.
https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/486#issuecomment-1032009193
@misterpeople I posted this on another issue as well. Since this here is the same error and problem as the other one, you should take a look at the fix I found. Just click the link below.
Thank you, Im getting another error maybe because im pointing it to Chromedriver? Im new in all of this maybe you could help?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
if __name__ == "__main__":
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://www.google.com/")
print(driver.title)
Error:
File "C:\Users\PC\Desktop\Bots\NewALi.py", line 7
PATH = "C:\Program Files (x86)\chromedriver.exe"
^
IndentationError: expected an indented block
[Finished in 528ms]
Welcome to the Python community!
import webbrowser
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
STACKOVERFLOW_SEARCH_API = "https://stackoverflow.com/search?"
if __name__ == "__main__":
service = Service(ChromeDriverManager(log_level=0).install())
driver = Chrome(service=service) # noqa
try:
driver.get("https://www.google.com/")
print(driver.title)
except Exception as e:
webbrowser.open(STACKOVERFLOW_SEARCH_API + f"q={e}")
finally:
driver.quit()
@misterpeople
@QIN2DIM did the right thing. You just need to indent the stuff. For everything like "if", "for", "while", and all these things, you need to indent everything that is in that once more than the actual "for", "if", etc statement.
Welcome to the Python Community.
Welcome to the Python community!
import webbrowser from selenium.webdriver import Chrome from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager STACKOVERFLOW_SEARCH_API = "https://stackoverflow.com/search?" if __name__ == "__main__": service = Service(ChromeDriverManager(log_level=0).install()) driver = Chrome(service=service) # noqa try: driver.get("https://www.google.com/") print(driver.title) except Exception as e: webbrowser.open(STACKOVERFLOW_SEARCH_API + f"q={e}") finally: driver.quit()
@misterpeople
@QIN2DIM did the right thing. You just need to indent the stuff. For everything like "if", "for", "while", and all these things, you need to indent everything that is in that once more than the actual "for", "if", etc statement.
Welcome to the Python Community.
Thank you both! although I dont see a use of the "import undetected_chromedriver.v2" Shouldnt it be there?
Welcome to the Python community!
import webbrowser from selenium.webdriver import Chrome from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager STACKOVERFLOW_SEARCH_API = "https://stackoverflow.com/search?" if __name__ == "__main__": service = Service(ChromeDriverManager(log_level=0).install()) driver = Chrome(service=service) # noqa try: driver.get("https://www.google.com/") print(driver.title) except Exception as e: webbrowser.open(STACKOVERFLOW_SEARCH_API + f"q={e}") finally: driver.quit()
@misterpeople @QIN2DIM did the right thing. You just need to indent the stuff. For everything like "if", "for", "while", and all these things, you need to indent everything that is in that once more than the actual "for", "if", etc statement. Welcome to the Python Community.
Thank you both! although I dont see a use of the "import undetected_chromedriver.v2" Shouldnt it be there?
@misterpeople We didn't check if your code works. Just wanted to explain that all the code that does something more than making a variable or import something, should be within that specific if statement. If you need that import statement, just add it.
@ultrafunkamsterdam i think you can close this one
Hey, im getting this error:
I have python 3.9.2, Chromedriver Version 98 & I've installed pip install undetected-chromedriver
Can someone help me? thanks