爬虫 - 解决 Executable path has been deprecated please pass in a Service object in Selenium Python 问题

2022/5/1 12:43:10

本文主要是介绍爬虫 - 解决 Executable path has been deprecated please pass in a Service object in Selenium Python 问题,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

# 1. 错误描述


# 2. 错误原因

出现 DeprecationWarning 警告的类型错误:该类型的警告大多属于版本更新时,所使用的方法过时的原因,他在当前版本被重构,还可以传入参数,但是在之后的某个版本会被删除.

查询当前版本重构后的函数,是之前的 executable_path 被重构到了 Service 函数里,如图


# 3. 解决方案

# -*- coding = utf-8 -*-
# @Time : 2021/10/16 17:47
# @Author : LIUYU
# @File : test_selenium.py
# @Software : PyCharm
 
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
 
s = Service(r"D:\Software\webdrivers\chromedriver.exe")
driver = webdriver.Chrome(service=s)
driver.get('https://www.baidu.com')
driver.close()

转自:https://www.dianjilingqu.com/



这篇关于爬虫 - 解决 Executable path has been deprecated please pass in a Service object in Selenium Python 问题的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程