Skip to content

Instantly share code, notes, and snippets.

@cecilialee
Last active February 24, 2018 07:26
Show Gist options
  • Save cecilialee/674010217a7152d698c21d293a83f959 to your computer and use it in GitHub Desktop.
Save cecilialee/674010217a7152d698c21d293a83f959 to your computer and use it in GitHub Desktop.
Launch Web browser in Python. #python #python3
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