According to Python's standard documentation, the webbrowser module provides a high-level interface to allow displaying Web-based documents to users. This topic explains and demonstrates proper usage of the webbrowser module.
webbrowser.open(url, new=0, autoraise=False)
webbrowser.open_new(url)
webbrowser.open_new_tab(url)
webbrowser.get(usage=None)
webbrowser.register(name, constructor, instance=None)
Parameter | Details |
---|---|
webbrowser.open() | |
url | the URL to open in the web browser |
new | 0 opens the URL in the existing tab, 1 opens in a new window, 2 opens in new tab |
autoraise | if set to True, the window will be moved on top of the other windows |
webbrowser.open_new() | |
url | the URL to open in the web browser |
webbrowser.open_new_tab() | |
url | the URL to open in the web browser |
webbrowser.get() | |
using | the browser to use |
webbrowser.register() | |
url | browser name |
constructor | path to the executable browser (help) |
instance | An instance of a web browser returned from the webbrowser.get() method |
The following table lists predefined browser types. The left column are names that can be passed into the webbrowser.get()
method and the right column lists the class names for each browser type.
Type Name | Class Name |
---|---|
'mozilla' | Mozilla('mozilla') |
'firefox' | Mozilla('mozilla') |
'netscape' | Mozilla('netscape') |
'galeon' | Galeon('galeon') |
'epiphany' | Galeon('epiphany') |
'skipstone' | BackgroundBrowser('skipstone') |
'kfmclient' | Konqueror() |
'konqueror' | Konqueror() |
'kfm' | Konqueror() |
'mosaic' | BackgroundBrowser('mosaic') |
'opera' | Opera() |
'grail' | Grail() |
'links' | GenericBrowser('links') |
'elinks' | Elinks('elinks') |
'lynx' | GenericBrowser('lynx') |
'w3m' | GenericBrowser('w3m') |
'windows-default' | WindowsDefault |
'macosx' | MacOSX('default') |
'safari' | MacOSX('safari') |
'google-chrome' | Chrome('google-chrome') |
'chrome' | Chrome('chrome') |
'chromium' | Chromium('chromium') |
'chromium-browser' | Chromium('chromium-browser') |