Python - 在Internet Explorer中打开多个标签页

0 投票
3 回答
2286 浏览
提问于 2025-04-16 08:00

我正在用这段代码在IE浏览器中打开谷歌...

ie = webbrowser.get('C:\\Program Files\\Internet Explorer\\IEXPLORE.exe')

ie.open('http://google.com")

不过我需要打开多个标签页,那我该怎么做呢?

3 个回答

0

我觉得这可能对你有帮助!你只需要等主窗口加载完成后再打开一个新标签页。

import win32com.client, time import webbrowser webbrowser.open_new_tab('http://www.yahoo.com') time.sleep(2) #等2秒 webbrowser.open_new_tab('http://www.google.com.br')

0
ie.open_new_tab('http://www.stackoverflow.com')

请查看这个链接:http://docs.python.org/library/webbrowser.html#webbrowser.open_new_tab

1

我还没有在IE浏览器上测试过,但这就是它应该工作的方式:

ie.open_new_tab(url1)
ie.open_new_tab(url2)
ie.open_new_tab(url3)

撰写回答