一、selenium版本环境

seleium版本:3.141.0
pip安装命令:pip install selenium==3.141.0

二、浏览器驱动下载

Chrome驱动:
Chrome130以后:链接
Chrome113-129以后:链接
Chrome114之前:链接
Edge:
链接

Firefox:
链接

Safari:
链接

三、配置浏览器驱动

3.1Chrome浏览器

#导入库
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options

options = Options()

# 设置 Chrome 驱动路径
driver_path="../call/chromedriver.exe"  # 替换为 chromedriver 的实际路径
driver = webdriver.Chrome(executable_path=driver_path, options=options)
#配置driver参数(可选)
driver.maximize_window()    #窗口最大化
driver.delete_all_cookies()  # 清空cookie
# 加载 HTML
driver.get(f"http://www.baidu.com")