网络浏览器Chrome,无法在新窗口中打开URL,并始终将打开的URL作为标签页

时间:2019-11-22 14:04:44

标签: python google-chrome

我正在尝试在新窗口中打开URL。我不能使用硒,因为它不会登录到Google。

我的默认浏览器是使用Windows 10的Chrome,我已经打开了三个带有多个标签的Chrome窗口。

这是我在Python 3.6上的代码:

import webbrowser

url = 'https://google.com'

open_google = webbrowser.open('https://google.com', new=1)
open_google = webbrowser.open_new('https://google.com')

这两个选项均在当前窗口中给了我一个新标签,而不是一个新窗口。为什么会这样呢?是Chrome中的设置吗?

1 个答案:

答案 0 :(得分:0)

如何使用os.system或子进程打开一个新窗口,然后使用webbrowser打开要在此处打开的url /应用程序。

类似的东西:

import subprocess
command = "cmd /c start chrome http://www.google.com --new-window"
subprocess.Popen(command, shell=True)

然后执行:

open_google = webbrowser.open('https://google.com', new=1)