bottle – How to open a URL in python

bottle – How to open a URL in python

with the webbrowser module

import webbrowser

webbrowser.open(http://example.com)  # Go to example.com
import webbrowser  
webbrowser.open(url, new=0, autoraise=True)

Display url using the default browser. If new is 0, the url is opened in the same browser window if possible. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page (“tab”) is opened if possible. If autoraise is True, the window is raised

webbrowser.open_new(url)

Open url in a new window of the default browser

webbrowser.open_new_tab(url)

Open url in a new page (“tab”) of the default browser

bottle – How to open a URL in python

On Windows

import os
os.system(start \ https://example.com)

On macOS

import os
os.system(open \ https://example.com)

On Linux

import os
os.system(xdg-open \ https://example.com)

Cross-Platform

import webbrowser

webbrowser.open(https://example.com)

Leave a Reply

Your email address will not be published. Required fields are marked *