how can i register the non-default browser with the webbrowser module?

Peter Otten __peter__ at web.de
Wed Sep 5 12:09:39 EDT 2012


Levi Nie wrote:

> how can i register the non-default browser with the webbrowser module?
> 
> the case:
> i want open a site such as "google.com" in ie8 with the python.But my
> default is chrome.
> so i want to register a ie8 controller with the
> webbrowser.register(*name*, *constructor*[, *instance*]).
> so what does the parameter "constructor" "instance" mean?
> how can i do it?

Isn't there already a controller for ie8? I can't check, but you can list 
the available browsers with

>>> import webbrowser
>>> list(webbrowser._browsers)
['x-www-browser', 'kfmclient', 'firefox', 'konqueror']

Then if you want to open a page with a specific browser just do

url = "http://www.python.org"
browser = "firefox"
webbrowser.get(browser).open(url)





More information about the Python-list mailing list