python实现打开浏览器的方法
发布时间:2020-08-24 16:10:20
来源:亿速云
阅读:98
作者:小新
这篇文章将为大家详细讲解有关python实现打开浏览器的方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
第一种:selenium导入浏览器驱动,用get方法打开浏览器,例如:import time
from selenium import webdriver
def mac():
driver = webdriver.Firefox()
driver.implicitly_wait(5)
driver.get("http://huazhu.gag/mis/main.do")
第二种:通过导入python的标准库webbrowser打开浏览器,例如:>>> 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实现打开浏览器的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。