The webbrowser module provides a very high-level interface to allow displaying Web-based documents to users. The controller objects are easy to use and are platform-independent. Under most circumstances, simply calling the open() function from this module will do the right thing.
Under Unix, graphical browsers are preferred under X11, but text-mode browsers will be used if graphical browsers are not available or an X11 display isn't available. If text-mode browsers are used, the calling process will block until the user exits the browser.
Under Unix, if the environment variable BROWSER exists, it
is interpreted to override the platform default list of browsers, as a
colon-separated list of browsers to try in order. When the value of
a list part contains the string %s
, then it is interpreted as
a literal browser command line to be used with the argument URL
substituted for the %s
; if the part does not contain
%s
, it is simply interpreted as the name of the browser to
launch.
For non-Unix platforms, or when X11 browsers are available on Unix, the controlling process will not wait for the user to finish with the browser, but allow the browser to maintain its own window on the display.
The following exception is defined:
The following functions are defined:
None
, constructor will be called without parameters to
create an instance when needed. If instance is provided,
constructor will never be called, and may be None
.
This entry point is only useful if you plan to either set the BROWSER variable or call get with a nonempty argument matching the name of a handler you declare.
A number of browser types are predefined. This table gives the type names that may be passed to the get() function and the corresponding instantiations for the controller classes, all defined in this module.
Type Name | Class Name | Notes |
---|---|---|
'mozilla' |
Netscape('mozilla') | |
'netscape' |
Netscape('netscape') | |
'mosaic' |
GenericBrowser('mosaic %s &') | |
'kfm' |
Konqueror() | (1) |
'grail' |
Grail() | |
'links' |
GenericBrowser('links %s') | |
'lynx' |
GenericBrowser('lynx %s') | |
'w3m' |
GenericBrowser('w3m %s') | |
'windows-default' |
WindowsDefault | (2) |
'internet-config' |
InternetConfig | (3) |
Notes: