selenium用不了edgedriver selenium怎么安装chrome驱动
selenium怎么安装chrome驱动
from selenium import webdriverimport osdef openBrowser(): #chromedriver需要你自行下载,这里需要给出你放置该driver的路径 chromedriver = "C:UsersSigmaAppDataLocalGoogleChromeApplicationchromedriver.exe" if not os.path.exists(chromedriver): chromedriver = C:Program FilesGoogleChromeApplicationchromedriver.exe os.environ["webdriver.chrome.driver"] = chromedriver browser = webdriver.Chrome(chromedriver) #fireFox不需要driver,只要安装了firefox,selenium会自动去找到它# browser = webdriver.Firefox() return browserdef closeBrowser(browser): browser.close() killAllDriver() def killAllDriver(): cmd = taskkill /F /IM chromedriver.exe os.system(cmd)