executable_path has been deprecated, please pass in a Service object

from selenium import webdriver

# 1.创建浏览器对象
# chrome = webdriver.Chrome(executable_path='C:/python310/chromedriver.exe')
# service = webdriver.chrome.service.Service('C:/python310/chromedriver.exe')

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

service = ChromeService(executable_path='C:/python310/chromedriver.exe')
chrome = webdriver.Chrome(service=service)


# 2.发起请求
chrome.get('https://www.baidu.com')

# 3.获取页面源码
page_text = chrome.page_source
# print(page_text)

# 获取标题
title = chrome.title
print(title)

原文链接: executable_path has been deprecated, please pass in a Service object 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://gyarmy.com/post-808.html )

发表评论

0则评论给“executable_path has been deprecated, please pass in a Service object”