Reputation: 3719
I want to open multiple Chrome tabs from within a program
The following command works perfectly from the terminal
google-chrome-stable www.google.com www.yahoo.com
How ever, when I run a python program containing
tabs = 'www.google.com www.yahoo.com'
subprocess.run(['google-chrome-stable', tabs],
stdin=None, stdout=None, stderr=subprocess.PIPE,
shell=False)
then urls get converted to
http://www.google.com%20www.yahoo.com/
How can I fix this?
I have tried
tabs = ['www.google.com', 'www.yahoo.com']
for tab in tabs:
subprocess.run(['google-chrome-stable', tab],
stdin=None, stdout=None, stderr=subprocess.PIPE,
shell=False)
But the program halts after each tab is opened and will not start again until the Chrome window containing the url is closed.
[Edit] Chrome is not my default browser and I don't want it to be, but I must use it for this application as there is a bespoke plug-in that I need to use
Upvotes: 0
Views: 1449
Reputation: 823
Try this it may work
import webbrowser
websites = ['www.google.com', 'www.reddit.com']
for url in websites:
webbrowser.open(url)
Upvotes: 1