Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python-Selenium4自动匹配和下载webdriver #96

Open
landv opened this issue Aug 26, 2024 · 0 comments
Open

Python-Selenium4自动匹配和下载webdriver #96

landv opened this issue Aug 26, 2024 · 0 comments

Comments

@landv
Copy link
Owner

landv commented Aug 26, 2024

# https://selenium.tutorial.hogwarts.ceshiren.com/web_auto_testing/L1/tutorial/SeleniumManager/
# https://github.com/SergeyPirogov/webdriver_manager
# Selenium4.0以上版本使用该方法
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

# 使用 ChromeDriverManager 安装 ChromeDriver,并返回驱动程序的路径
driver_path = ChromeDriverManager().install()
# 打印驱动程序的路径
print(driver_path)

# 创建 ChromeDriver 服务,并指定驱动程序的路径
service = Service(driver_path)
# 创建 Chrome WebDriver,并指定服务
driver = webdriver.Chrome(service=service)
# 打开百度网页
driver.get("https://www.baidu.com")

input()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant