Change language

Convenient Python web browser controller

There is a module called webbrowser for displaying web documents to users using python. It provides a high-level interface for processing web documents.

On UNIX systems, this module supports the browsers lynx, Netscape, Mosaic, etc. For Windows and Macintosh, it uses standard browsers.

To use this module, we need to import the following module.



 import webbrowser 

The webbrowser module has different methods and exceptions as follows:

The webbrowser.Error exception

This error will be thrown when an error occurs in the web browser interface.

The webbrowser.open (url, new = 0, autoraise = True) method

This method is used to display the URL using default web browser. The default value for new is 0. When it is 0, it opens in the same browser, for new = 1, a new browser window opens, and for new = 2, a new browser tab opens.

webbrowser.open_new method (url)

This method is used to return a controller for the browser type using. If use is None, it will return the default browser controller.

The webbrowser.register method (name, constructor, instance = no, *, preference = false)

This method is used to register the name of the browser type. After registration, we can get the browser controller using the get () method. There is an instance in the parameter, when no instance is defined, the constructor will be called without any parameter.


There are several predefined browser types. Here is a list of some of the selected browser types. These types can be passed as a get () method.

& # 8216; Mozilla & # 8217;

Mozilla

& # 8216; Fire Fox

Mozilla

& # 8216; Netscape & # 8217;

Mozilla (& # 8216; Netscape & # 8217; )

Opera

Opera()



Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method