如何从Python或CLI在Firefox中打开新选项卡?
我正在使用CLI方式为多个站点打开Firefox。我正在使用以下代码,但它在我的Mac上的第一个站点被卡住了:如何从Python或CLI在Firefox中打开新选项卡?,python,automation,Python,Automation,我正在使用CLI方式为多个站点打开Firefox。我正在使用以下代码,但它在我的Mac上的第一个站点被卡住了: def launch_sites(is_linux=True): if is_linux: cmd = 'firefox --new-tab http://adnansiddiqi.me' push = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) result
def launch_sites(is_linux=True):
if is_linux:
cmd = 'firefox --new-tab http://adnansiddiqi.me'
push = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
result = push.stdout.read()
result = str(result, 'utf-8')
cmd = 'firefox --new-tab http://google.com'
push = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
result = push.stdout.read()
result = str(result, 'utf-8')
else:
cmd = '/Applications/Firefox.app/Contents/MacOS/firefox-bin http://adnansiddiqi.me'
push = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
result = push.stdout.read()
result = str(result, 'utf-8')
cmd = '/Applications/Firefox.app/Contents/MacOS/firefox-bin http://google.com'
push = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
result = push.stdout.read()
result = str(result, 'utf-8')
目标是一次在选项卡中打开所有这些站点。我得到的错误是:
C[GFX1-]: Receive IPC close with reason=AbnormalShutdown
[GFX1-]: Receive IPC close with reason=AbnormalShutdown
Exiting due to channel error.
Exiting due to channel error.
[GFX1-]: Receive IPC close with reason=AbnormalShutdown
[GFX1-]: Receive IPC close with reason=AbnormalShutdown
Exiting due to channel error.
Exiting due to channel error.
你可以试试这个
firefox——帮助
输出为
......
--new-window <url> Open <url> in a new window.
--new-tab <url> Open <url> in a new tab.
......
。。。。。。
--新窗口在新窗口中打开。
--新选项卡在新选项卡中打开。
......