chromedriver驱动安装
时间: 2023-09-10 09:11:20 浏览: 113
您好!如果您想要自动化安装 ChromeDriver 驱动,可以使用以下 Python 脚本来实现:
```python
import os
import zipfile
from urllib.request import urlretrieve
# 设置 ChromeDriver 版本和下载地址
chrome_driver_version = "88.0.4324.96"
chrome_driver_url = f"https://chromedriver.storage.googleapis.com/{chrome_driver_version}/chromedriver_win32.zip"
driver_zip_file = "chromedriver_win32.zip"
driver_folder = "chromedriver"
# 下载 ChromeDriver 压缩文件
urlretrieve(chrome_driver_url, driver_zip_file)
# 解压缩文件
with zipfile.ZipFile(driver_zip_file, 'r') as zip_ref:
zip_ref.extractall(driver_folder)
# 添加 ChromeDriver 路径到环境变量
driver_path = os.path.join(os.getcwd(), driver_folder)
os.environ["PATH"] += os.pathsep + driver_path
# 清理工作文件
os.remove(
阅读全文