Python使用指定浏览器打开指定个数的指定网页

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38208401/article/details/85263158

1、系统自带库 os

支持任何浏览器

import os
os.system('"C:\Program Files\Google\Chrome\Application\chrome.exe" http://www.baidu.com')

2、python集成的库 webbroswer

需要指定浏览器,需要注册;未注册则使用默认浏览器

import webbrowser
url = 'http://www.baidu.com'
chromePath = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chromePath)) 
b = webbrowser.get('chrome')
b.open(url,new=1,autoraise=True)

两种方式,加上循环就能打开N个了

猜你喜欢

转载自blog.csdn.net/weixin_38208401/article/details/85263158