我已经看到一些与此相关的问题,但我仍然遇到问题。当Firefox不是默认浏览器时,使用Firefox打开HTML文件
运行代码:与
>>>webbrowser.get('firefox')
错误:
webbrowser.Error: could not locate runnable browser
要解决我跑:
>>>print(webbrowser._browser)
{'windows-default': [<class 'webbrowser.WindowsDefault'>, None], 'c:\\program files\\internet explorer\\iexplorer.exe': [None, <webbrowser.BackgroundBrowser object at 0x000000000651FEB8>]}
奇怪的是,我安装了Firefox,它是我的默认浏览器,并且我试图通过Python打开的HTML文件以Firefox打开。
除了我需要将此程序发送给可能将IE设置为其默认Windows默认设置的用户,并且必须在Firefox中打开HTML文件之外,所有内容都适用于该世界。
你可以安装硒和做webdriver.Firefox() –