【Selenium4_python】无需加载浏览器驱动,但是首次加载过慢(自动下载浏览器驱动)

默认自动加载驱动到:C:\Users\用户名\.cache\selenium下,可以将文件夹下的驱动放到本地一个固定位置,或者当前项目文件夹下:

用Service对象加载本地驱动:

options = webdriver.ChromeOptions()
options.pageLoadSreategy = "eager"
service = Service("../service_driver/chromedriver_127.0.6533.119_x64.exe")
# service = Service(r"D:\Program Files\Python312\chromedriver_127.0.6533.119_x64.exe")
driver = webdriver.Chrome(options=options,service=service)

  

posted @ 2024-08-21 11:43  ninarMing  阅读(3)  评论(0编辑  收藏  举报