赞
踩
NoSuchDriverException(msg) from err
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge using Selenium Manager.;
For documentation on this error, please visit:
https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
很简单直接的解决方法就是我们直接指定浏览器驱动的位置即可。
from selenium import webdriver
# 启动浏览器
service = webdriver.EdgeService(executable_path='./msedgedriver.exe') # 指定驱动的路径
driver = webdriver.Edge(service=service)
from selenium import webdriver # https://zhuanlan.zhihu.com/p/557463669 # 启动浏览器 service = webdriver.EdgeService(executable_path='./msedgedriver.exe') driver = webdriver.Edge(service=service) # 打开目标网页 target_url = "https://boot-video.xuexi.cn/video/1006/p/5fd0919e562a1eedd1a8f740849f491a-72ee9dcf0fa440d7b8974dbea2538d39-2.mp4" driver.get(target_url) # 页面操作 driver.set_window_size(480, 800) # 页面大小 driver.back() # 后退 driver.forward() # 前进 driver.refresh() # 刷新 driver.save_screenshot("./1.png") # 页面截图
参考:https://www.selenium.dev/documentation/webdriver/drivers/service/#driver-location
示例参考:https://zhuanlan.zhihu.com/p/557463669
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。