Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a new default browser window in Python when the default is Chrome

Tags:

python

browser

I have been looking for a way to open a new default browser window from inside Python code.

According to the documentation webbrowser.open_new(url) Should do that. Unfortunately in case Chrome is the default browser it only opens a new tab. Is there any way to open the default browser (without knowing what that browser is)?

like image 225
Veet Vivarto Avatar asked Sep 22 '11 21:09

Veet Vivarto


1 Answers

Give this a whirl:

import subprocess
command = "cmd /c start chrome http://www.ebay.com --new-window"
subprocess.Popen(command, shell=True)
like image 98
Phaxmohdem Avatar answered Oct 04 '22 15:10

Phaxmohdem