[英]How to open url with opera in incognito mode?
This is the code that opens opera in incognito, but I have no idea how to open URL in incognito.这是在隐身模式下打开歌剧的代码,但我不知道如何在隐身模式下打开 URL。
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
:
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.subprocess.run
是在 Python 3.5 中添加的,作为对subprocess.Popen
的简化,当您只想执行命令并等待它完成时,但您不想同时做任何其他事情。
To open URL by command line, you have to use --remote <url>
parameter要通过命令行打开 URL,您必须使用--remote <url>
参数
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
如果您使用的是 python < 3.5,请将subprocess.run
替换为subprocess.Popen
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.