How to Open Up a New Web Browser Using Python 


               


How to Open Up a New Web Browser Using Python



Python


In this article, we show how to open up a new web browser using Python.

This gives us access to any page on the web.

This is important because this is the first step to gaining access to a web page. We then use other python modules to extract data from the web or do anything that we need to do with the web page. But the first step is obviously opening up the web page and we can do this through the Python webbbrowser.open() function.

This is actually really easy.

The full code is shown below, just 2 lines.



So first we have to import the webbrowser module.

Once this is done, we just use the webbrowser.open() function to open the web page that we want to. In the example above, we open the website, dropbox.

Once we run this program, the python IDLE returns true and then immediately opens a web browser to the web page that you specified.

A new web browser tab will open up in your web browser if your web browser is already in use.

This is about the only thing the webbrowser module can do.

The Python IDLE with the code in it is shown below so you can see.

Python webbrowser open function

This goes to the dropbox website.


Related Resources

How to Measure the Length of a String in Python



HTML Comment Box is loading comments...