Last active
February 24, 2018 07:26
-
-
Save cecilialee/674010217a7152d698c21d293a83f959 to your computer and use it in GitHub Desktop.
Launch Web browser in Python. #python #python3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import webbrowser | |
url = 'http://idiotinside.com' | |
# Open URL in new browser window | |
webbrowser.open_new(url) # opens in default browser | |
# Opens in safari browser | |
webbrowser.get('safari').open_new(url) | |
# Open URL in a new tab | |
webbrowser.open_new_tab(url) # opens in default browser | |
# Opens in safari browser | |
webbrowser.get('safari').open_new_tab(url) | |
# Tutorial: http://www.idiotinside.com/2015/03/07/open-an-url-on-web-browser-programmatically-in-python | |
# Documentation: https://docs.python.org/3/library/webbrowser.html | |
# Tested on Python 2.7.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment