I'm trying to launch a website url in a new tab using python in that way, but it didn't worked in these both ways:
Method 1:
os.system('C:\Program Files\Mozilla Firefox\Firefox.exe -new-tab http://www.google.com/');
and Method 2:
os.startfile('C:\Program Files\Mozilla Firefox\Firefox.exe -new-tab http://www.google.com/');
If I don't add the parameters (-new-tab http://www.google.com/) it works, opening the default page.
there are multiple way of opening URL in python using different packages-
using selenium package-
download firefox driver and placed at user/username/bon location and change the name to firefox.
using sub-process package-
using mechanize package-
using web-browser package-
closing opened web page-
same information in some more detail is mentioned here- http://pythonfordatabuggers.blogspot.com/2020/04/automatically-open-and-do-some-actions.html
You might want to try:
If you are using python 2.7 on windows 7 machine (my setup), if you use:
It will open legacy windows explorer (yeah I know right...).
BUT, if you use:
It will load the url in you default web browser, in my case Firefox.
If you want to start a program with parameters the subprocess module is a better fit:
You need to use the
webbrowser
module[edit]
If you want to open a url in a non-default browser try: