Reputation: 82
I want to open google chrome browser and go to facebook and terminate the python program but keep the google chrome window open until I manually close it. Please give me your own idea/Program with the above said as the aim.
I expect the chrome window to remain open after the program terminates, but it closes automatically after the program terminates.
Upvotes: 2
Views: 814
Reputation: 4383
Using os.system()
should be avoided because it is platform dependent and because it isn't secure: if you use os.system('start chrome "%s"') % url
where url
is a string submitted by the user, someone can enter www.facebook.com" && shutdown /s /t "0
Facebook will open in a new Chrome window but then the computer will shut down.
The easiest way to open a new page in the browser is:
import webbrowser
webbrowser.open_new("www.facebook.com")
It remains open when the Python script terminates.
Upvotes: 2
Reputation: 21
Try this, works on windows!
import os
os.system("start chrome \"www.facebook.com\"")
This shall open a chrome browser with the Facebook URL using cmd and it remains open even after the termination of the program.
Upvotes: 0