在使用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)
刚开始觉得是火狐浏览器和驱动的问题,查阅资料之后发现是代码的问题文章来源:https://www.toymoban.com/news/detail-620662.html
将代码改为如下之后能打开浏览器文章来源地址https://www.toymoban.com/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)
到了这里,关于报错: DeprecationWarning: executable_path has been deprecated, please pass in a Service object的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!