The webbrowser
library provides a convenient way to launch a URL with a browser window through the webbrowser.open()
method. Numerous browser types are available, but there does not appear to be an explicit way to launch Internet Explorer when running python on windows.
WindowsDefault
only works if Internet Explorer is set as the default browser, which is not an assumption I can make.
Is there a way to explicitly launch a URL into Internet Explorer without reverting to windows API calls?
>>> ie = webbrowser.get('c:\\program files\\internet explorer\\iexplore.exe')
>>> ie.open('http://google.com')
True
iexplore = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"),
"Internet Explorer\\IEXPLORE.EXE")
ie = webbrowser.BackgroundBrowser(iexplore)
ie.open(...)
This is what the webrowser
module uses internally.
More elegant code:
import webbrowser
ie = webbrowser.get(webbrowser.iexplore)
ie.open('google.com')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With