syntax error in python while trying to use selenium webdriver

Viewed 47

i am trying to use Selenium in python, with this code below. I tried to give Path ( as I saw in documentation) inside driver.Chrome("..") where the chromedriver.exe exists.

from selenium import webdriver

driver = webdriver.Chrome("C:\Users\Admin\AppData\Local\Programs\Python\Python310\Lib\site-packages\selenium\webdriver\chromium\chromedriver.exe")
driver.get("https://www1.nseindia.com/products/content/derivatives/equities/historical_fo.htm")

I get the error:

C:\Users\Admin\AppData\Local\Programs\Python\Python310\python.exe C:/pythonPro/t_bot/se_nba.py 
  File "C:\pythonPro\t_bot\se_nba.py", line 3
    driver = webdriver.Chrome("C:\Users\Admin\AppData\Local\Programs\Python\Python310\Lib\site-packages\selenium\webdriver\chromium\chromedriver.exe")
                                                                                                                                                     ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

I don't think it's because of the double question mark because I tried it with a single question mark as well. The same error occurs.

a possible response to this question (requires acknowledgement)

# selenium 4
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
0 Answers
Related