Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Python或CLI在Firefox中打开新选项卡?_Python_Automation - Fatal编程技术网

如何从Python或CLI在Firefox中打开新选项卡?

如何从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

我正在使用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 = 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.
......
。。。。。。
--新窗口在新窗口中打开。
--新选项卡在新选项卡中打开。
......