如何解决如何使用Python网络浏览器保持Google开放?
我正在尝试通过python webbrowser打开多个Google页面,并且已经可以使用,但是在打开所有页面后,除非我手动单击,否则Google会关闭。为什么会这样呢?感谢您的帮助,在此先感谢。
import pyautogui as py
import keyboard as key
import time
chrome_path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
webbrowser.register('chrome',None,webbrowser.BackgroundBrowser(chrome_path))
def n_t():
py.hotkey('ctrl','t')
def m_t():
py.hotkey('ctrl','tab')
def gogle():
webbrowser.get('chrome').open('gmail.com')
py.press('enter')
time.sleep(5)
n_t()
py.write('www.youtube.com')
py.press('enter')
n_t()
py.write('hangouts.google.com/authuser=2')
py.press('enter')
n_t()
py.write('stackoverflow.com')
py.press('enter')
m_t()
gogle()
解决方法
使用此:
import webbrowser
webbrowser.open('https://google.com')
webbrowser.open('https://gmail.com')
webbrowser.open('https://youtube.com')
webbrowser.open('https://stackoverflow.com')
您很高兴。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。