This is the code that opens opera in incognito, but I have no idea how to open URL in incognito.
import subprocess
command = '"C:\\Users\\Igor\\AppData\\Local\\Programs\\Opera\\launcher.exe" --private'
subprocess.Popen(command)`
Could anyone help me with this? Thanks
If you need only to open your opera in private mode, you can use subprocess.run
:
subprocess.run
was added in Python 3.5 as a simplification oversubprocess.Popen
when you just want to execute a command and wait until it finishes, but you don't want to do anything else meanwhile.
To open URL by command line, you have to use --remote <url>
parameter
So, your code can look like this:
import subprocess
def run_opera_private():
cmd = r'C:\Users\Igor\AppData\Local\Programs\Opera\launcher.exe --private --remote <url>'
#example cmd=r'C:\Users\karol\AppData\Local\Programs\Opera\launcher.exe --private --remote google.com'
subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if __name__ == '__main__':
run_opera_private()
If you are using python < 3.5, replace subprocess.run
with subprocess.Popen