我是靠谱客的博主 生动黑裤,这篇文章主要介绍报错: DeprecationWarning: executable_path has been deprecated, please pass in a Service object,现在分享给大家,希望可以做个参考。

在使用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:pythonchubanshegeckodriver.exe')
chrome.get(url)

刚开始觉得是火狐浏览器和驱动的问题,查阅资料之后发现是代码的问题

将代码改为如下之后能打开浏览器

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

driver = webdriver.Firefox(service =Service("D:pythonchubanshegeckodriver.exe"))
url='http://baidu.com'
driver.get(url)

最后

以上就是生动黑裤最近收集整理的关于报错: DeprecationWarning: executable_path has been deprecated, please pass in a Service object的全部内容,更多相关报错:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(169)

评论列表共有 0 条评论

立即
投稿
返回
顶部