在使用selenium的時(shí)候運(yùn)行如下代碼的時(shí)候報(bào)出錯(cuò)誤 :DeprecationWarning: executable_path has been deprecated, please pass in a Service object
from selenium.webdriver import Chrome
url='https://www.baidu.com'
chrome=Chrome(executable_path='D:\python\chubanshe\geckodriver.exe')
chrome.get(url)
剛開始覺得是火狐瀏覽器和驅(qū)動(dòng)的問題,查閱資料之后發(fā)現(xiàn)是代碼的問題文章來源:http://www.zghlxwxcb.cn/news/detail-620662.html
將代碼改為如下之后能打開瀏覽器文章來源地址http://www.zghlxwxcb.cn/news/detail-620662.html
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
driver = webdriver.Firefox(service =Service("D:\python\chubanshe\geckodriver.exe"))
url='http://baidu.com'
driver.get(url)
到了這里,關(guān)于報(bào)錯(cuò): DeprecationWarning: executable_path has been deprecated, please pass in a Service object的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!