#coding=utf-8
from selenium import webdriver
import time
def browser(browser):
'''打开火狐、谷歌、ie浏览器用法,如谷歌:driver=browser('chrome')'''
try:
if browser=="firefox":
driver=webdriver.Firefox()
return driver
elif browser=="chrome":
driver=webdriver.Chrome()
return driver
else:
print("Not found browser!You can enter 'firefox','chrome'")
except Exception as msg:
print("open browser error:%s"%msg)
if __name__=="__main__":
# 用火狐浏览器打开百度网页
driver_firefox=browser('firefox')
driver_firefox.get("https://www.baidu")
# 获取浏览器的名称
print("open browser:%s"%driver_firefox.name)
# 获取网页名称
print(driver_firefox.title)
# 用谷歌浏览器打开天龟网页
driver_chrome=browser("chrome")
driver_chrome.get("http://www.tianguiedu")
# 获取浏览器的名称
print("open browser: %s"%driver_chrome.name)
# 获取网页名称
print(driver_chrome.title)
time.sleep(5)|#休眠5秒
driver_chrome.quit()#谷歌浏览器不关闭网页会报错
Python打开指定浏览器的指定网页
与本文相关的文章
- 用 ChatGPT 网页爬虫发现隐藏的网络数据
- ChatGPT API 比网页版更智能吗?
- 部署专属网页版ChatGPT-Next-Web
- (AlGC小站,Free2gpt,GPT4 | ora.ai,智能助手,chatGAi,Chatgpt在线网页版)分享6个好用的chatGPT
- 基于ChatGPT等大模型快速爬虫提取网页内容
- ChatGPT对话:如何制作静态网页?
- 免费1年服务器,部署个ChatGPT专属网页版
- 利用chatGPT plus插件读取网页及本地文件
- 免登录ChatGPT联网版GPT-3GPT-4,还可发送网站链接总结网页内容 - TDChat
- 在 Armbian 中下载和安装最新版的 Python 3
- 在线网页版ps
- Python系列(亲测有效):You should consider upgrading via the ‘python -m pip install --upgrade pip‘ command
- You should consider upgrading via the ‘python -m pip install --upgrade pip‘ command.
- You should consider upgrading via the‘D:developpythonpython.exe -m pip install --upgrade pip‘ com
- 【无标题】You should consider upgrading via the ‘python -m pip install --upgrade pip‘ command.解决方法:
- 【Python】使用pip安装第三方库报错 You should consider upgrading via the ‘python -m pip install --upgrade pip‘
- 分享5款免费在线ps网页版工具,在线ps图片编辑器
- Python, filter vectors from Pinecone vector store based on a field saved in the metadata of these vectors - Stack Overflow
- 电脑连接上WiFi,但是没法使用||浏览器检测到网络已更改
- 电脑wifi网络连接,可以上QQ和微信但是无法浏览器无法使用解决方法【自留】
评论列表(0)
- 暂无评论