(Aug-24-2023, 08:53 AM)cate16 Wrote: Since I am very new to Python, I haven't understand what you mean. Do I have to put this in what part of the code?Now you shall open cmd and type
echo %PATH:;=&echo.%
with <enter> then will get a list of folders.So in one those folder you most place
chromedriver.exe
,these are Environment Variables Path Here a working example.
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By import time # Setup #https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5795.0/win64/chromedriver-win64.zip options = Options() options.add_argument("--headless=new") ser = Service(r"C:\cmder\bin\chromedriver.exe") browser = webdriver.Chrome(service=ser, options=options) # Parse or automation url = 'https://www.palottery.state.pa.us/Draw-Games/Treasure-Hunt.aspx' browser.get(url) lotto_number = browser.find_element(By.CSS_SELECTOR, 'div.details') print(lotto_number.text)
Output:0106091523
So i have C:\cmder\bin
in my OS Path.It i use
cmd
,see that folder is there eg also folder C:\WINDOWS
would work to place chromedriver.exe
in.Microsoft Windows [Version 10.0.19045.3324] (c) Microsoft Corporation. Med enerett. C:\>%PATH:;=&echo.% ..... C:\cmder\bin C:\WINDOWS\system32 C:\WINDOWS .... C:\>