Python Language Webbrowser Module

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

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.

Syntax

  • 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)

Parameters

ParameterDetails
webbrowser.open() 
urlthe URL to open in the web browser
new0 opens the URL in the existing tab, 1 opens in a new window, 2 opens in new tab
autoraiseif set to True, the window will be moved on top of the other windows
webbrowser.open_new() 
urlthe URL to open in the web browser
webbrowser.open_new_tab() 
urlthe URL to open in the web browser
webbrowser.get() 
usingthe browser to use
webbrowser.register() 
urlbrowser name
constructorpath to the executable browser (help)
instanceAn instance of a web browser returned from the webbrowser.get() method

Remarks

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 NameClass 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')


Got any Python Language Question?