本文摘自php中文网,作者尚,侵删。

第一种:selenium导入浏览器驱动,用get方法打开浏览器,例如:
1 2 3 4 5 6 | import time
from selenium import webdriver
def mac():
driver = webdriver.Firefox()
driver.implicitly_wait(5)
driver.get( "http://huazhu.gag.com/mis/main.do" )
|
第二种:通过导入python的标准库webbrowser打开浏览器,例如:
1 2 3 4 5 | >>> import webbrowser
>>> webbrowser.open( "C:\\Program Files\\Internet Explorer\\iexplore.exe" )
True
>>> webbrowser.open( "C:\\Program Files\\Internet Explorer\\iexplore.exe" )
True
|
第三种:使用Splinter模块模块
Splinter的使用必修依靠Cython、lxml、selenium这三个软件。所以,安装前请提前安装
Cython、lxml、selenium。
阅读剩余部分
相关阅读 >>
Python语言有什么特点
Python如何创建空列表
Python使用代理ip访问网站
Python如何写入csv
Python是机器语言吗
怎么看安装了哪些第三方库在Python
selenium定时刷新网页的代码示例
实例详解关于golang中for-loop与goroutine
Python如何读取excel表数据
如何获取一个文件的创建和修改时间
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » python如何实现打开浏览器