小编Kay*_*199的帖子

如何使用 Web 浏览器从 Python 脚本启动 Microsoft Edge

使用webbrowser lib,我可以从 python 脚本启动 Chrome 和 Firefox。Edge 则失败了。我注意到使用webdriver启动 Edge 的方法,但我的问题是是否可以使用以下脚本来启动 Edge。目前它仅启动 Chrome。

import webbrowser

chrome_path="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
edge_path="C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe"

webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path))
webbrowser.register('edge', None, webbrowser.BackgroundBrowser(edge_path))

webbrowser.get('chrome').open('http://www.google.com')
webbrowser.get('edge').open('http://www.microsoft.com')
Run Code Online (Sandbox Code Playgroud)

python python-webbrowser

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×1

python-webbrowser ×1