Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to operating system to open url?

What can I use to call the OS to open a URL in whatever browser the user has as default? Not worried about cross-OS compatibility; if it works in linux thats enough for me!

like image 712
Bolster Avatar asked Nov 18 '10 16:11

Bolster


People also ask

How do I open a URL in Python?

just open the python interpreter and type webbrowser. open('http://www.google.com') and see if it does what you want. yes. The result is same.


1 Answers

Here is how to open the user's default browser with a given url:

import webbrowser  url = "https://www.google.com/"  webbrowser.open(url, new=0, autoraise=True) 

Here is the documentation about this functionality. It's part of Python's stdlibs:

http://docs.python.org/library/webbrowser.html

I have tested this successfully on Linux, Ubuntu 10.10.

like image 120
kobrien Avatar answered Oct 14 '22 18:10

kobrien