Personally, I really would not use the webbrowser module.
This is a complex sniffing mess for certain browsers that will not find the user's default browser if they have more than one installed, and will not find the browser if he does not know his name (for example, Chrome).
It's best on Windows just to use the os.startfile function, which also works with the url. In OS X, you can use the open system command. Linux has xdg-open , a standard freedesktop.org command supported by GNOME, KDE, and XFCE.
if sys.platform=='win32': os.startfile(url) elif sys.platform=='darwin': subprocess.Popen(['open', url]) else: try: subprocess.Popen(['xdg-open', url]) except OSError: print 'Please open a browser on: '+url
This will provide the best user experience on major platforms. Perhaps you could return to webbrowser on other platforms. Although, most likely, if you are in an obscure / unusual / embedded OS, where none of the above tasks has a chance on a webbrowser .
bobince Nov 18 2018-10-18 16:43
source share