在使用selenium的时候运行如下代码的时候报出错误 :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)
刚开始觉得是火狐浏览器和驱动的问题,查阅资料之后发现是代码的问题
将代码改为如下之后能打开浏览器
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)