如何在隐身模式下使用 Opera 打开 url?
How to open url with opera in incognito mode?
这是隐身打开歌剧的代码,但我不知道如何在隐身模式下打开URL。
import subprocess
command = '"C:\Users\Igor\AppData\Local\Programs\Opera\launcher.exe" --private'
subprocess.Popen(command)`
谁能帮我解决这个问题?谢谢
在 Windows 10 Pro
上测试
如果你只需要在私人模式下打开你的歌剧,你可以使用subprocess.run
:
subprocess.run
was added in Python 3.5 as a simplification over subprocess.Popen
when you just want to execute a command and wait until it finishes, but you don't want to do anything else meanwhile.
要通过命令行打开URL,您必须使用--remote <url>
参数
因此,您的代码可以如下所示:
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()
如果您使用的是 python < 3.5,请将 subprocess.run
替换为 subprocess.Popen
这是隐身打开歌剧的代码,但我不知道如何在隐身模式下打开URL。
import subprocess
command = '"C:\Users\Igor\AppData\Local\Programs\Opera\launcher.exe" --private'
subprocess.Popen(command)`
谁能帮我解决这个问题?谢谢
在 Windows 10 Pro
上测试如果你只需要在私人模式下打开你的歌剧,你可以使用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.
要通过命令行打开URL,您必须使用--remote <url>
参数
因此,您的代码可以如下所示:
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()
如果您使用的是 python < 3.5,请将 subprocess.run
替换为 subprocess.Popen