How to Open URL in Firefox Browser from Python Application?

Python – Open URL in Firefox Browser

You can open URL in a browser and also specify to open the URL in Firefox browser specifically, from your Python Application.

To open URL in a browser, we will use webbrowser Python module.

Step-by-step Process

Follow these steps to open URL in Firefox Browser.

  1. Register the browser type name using webbrowser.register(). Also provide the browser executable file path.
  2. Get the controller object for the browser using webbrowser.get() and Open URL using open().

Example 1: Open URL in Firefox

In the following example, we will open https://pythonexamples.org in Firefox browser.

Python Program

import webbrowser

url = 'https://pythonexamples.org'
webbrowser.register('firefox',
	None,
	webbrowser.BackgroundBrowser("C://Program Files//Mozilla Firefox//firefox.exe"))
webbrowser.get('firefox').open(url)
Run this program ONLINE

Output

Summary

In this tutorial of Python Examples, we learned how to open a URL in Firefox browser.