小编Pra*_*jan的帖子

如何使用 Python 在新选项卡中打开 Google Chrome 中的 URL?

我使用下面的代码打开一个新的 chrome 浏览器窗口。当我运行代码时,它总是在现有选项卡中打开一个新页面。

import webbrowser
import pyautogui

url = 'google.com'
chrome_path = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path))
webbrowser.get('chrome').open_new(url)

print(pyautogui.position())
Run Code Online (Sandbox Code Playgroud)

有人可以建议如何打开一个新选项卡吗?

google-chrome python-webbrowser pyautogui

2
推荐指数
1
解决办法
5485
查看次数