Selenium WebDriver 的 Microsoft Edge 驱动程序【附代码】

1、从 Microsoft Edge 驱动程序的官方网站下载与浏览器版本相匹配的驱动程序。

https://msedgewebdriverstorage.z22.web.core.windows.net/https://msedgewebdriverstorage.z22.web.core.windows.net/

2、指向驱动程序(**msedgedriver.exe)**的路径

复制代码
service = Service('./msedgedriver.exe')

3、启动驱动程序

复制代码
browser = webdriver.Edge(service=service, options=options) 

4、关闭浏览器会话

复制代码
browser.quit()

例如:

startBrowser 方法

Python 类中用于初始化和启动 Microsoft Edge 浏览器会话的一个成员函数,这个方法使用了 Selenium WebDriver 来创建和配置浏览器实例

复制代码
     def startBrowser(self):
        service = Service('./msedgedriver.exe')
        options = webdriver.EdgeOptions()  # 创建浏览器选项实例
        options.add_experimental_option('excludeSwitches', ['enable-automation'])
        browser = webdriver.Edge(service=service, options=options)
        # 使用 webdriver.Edge 与 service 和 options 一起创建了一个新的 Edge 浏览器实例

        return browser
相关推荐
铁皮哥4 小时前
【agent 开发】Claude Code 的 Skill 是怎么被加载的?从 name/description 到 SKILL.md 再到资源文件
java·服务器·数据库·python·gitee·github·软件工程
py小王子4 小时前
期刊复现|Python 实现带误差棒与3D 柱状数据可视化
python·期刊复现
财经资讯数据_灵砚智能4 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(夜间-次晨)2026年5月25日
大数据·人工智能·python·信息可视化·自然语言处理·ai编程
是你就无限6154 小时前
FastAPI 核心技术与实战
python·fastapi
是上好佳佳佳呀4 小时前
【Python基础|DAY05】Python 模块与包
python
大数据魔法师5 小时前
Streamlit(十一)- API 参考文档(四)- 图表元素
python·web
wh_xia_jun5 小时前
HttpRunner 入门
测试工具
AllData公司负责人5 小时前
亲测丝滑,体验跃迁|AllData通过集成开源项目Datart,让数据可视化一目了然
java·大数据·数据库·python·数据可视化·数据视图·datart
tang777895 小时前
2026代理IP选型逻辑与成本控制:动态IP VS 静态IP、住宅IP VS 运营商IP VS 数据中心IP的深入解析
爬虫·python·代理ip·住宅ip·住宅代理·运营商ip
AI玫瑰助手5 小时前
Python函数:def定义函数与参数传递基础
android·开发语言·python