我已經看到一些與此相關的問題,但我仍然遇到問題。當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() –