Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open IE Browser Window

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?

like image 988
Karmic Coder Avatar asked Oct 07 '09 16:10

Karmic Coder


3 Answers

>>> ie = webbrowser.get('c:\\program files\\internet explorer\\iexplore.exe')
>>> ie.open('http://google.com')
True
like image 78
SilentGhost Avatar answered Oct 18 '22 20:10

SilentGhost


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.

like image 34
Lukáš Lalinský Avatar answered Oct 18 '22 21:10

Lukáš Lalinský


More elegant code:

import webbrowser

ie = webbrowser.get(webbrowser.iexplore)
ie.open('google.com')
like image 24
C.H.S. Avatar answered Oct 18 '22 21:10

C.H.S.