Display a web page in the browser using the Python module WebBrowser

The webbrowser module of Python standard library provides a set of functions to display a web page corresponding to a URL in the default or one of the other browsers available in the system. The python example opens the default browser which is firefox and renders the web page.

Webbrowser Updated 24 Sep 2019 1 min read

Overview

  • The WebBrowser module of Python standard library provides a set of functions to display a webpage corresponding to a URL on the web browser available in the system.
  • If the web browser is a text-mode browser launched on command line itself, then the process corresponding to the Python program waits till the browser exits. Else they run independently after a browser process is pawned.

Example

python
# Example python program that opens a url in the default browser

# available in the system

import webbrowser

# URL to be opened in the browser

url = "https://www.example.com"

# Open the url in the default browser

webbrowser.open(url);

Output

URL opened through the open function of Python's webbrowser module