python 爬虫 -----selenium自动化测试工具的使用 + Microsoft edge driver 的安装

  • selenium 的安装

python -m pip --default-timeout=100 install selenium -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

 

  • Microsoft edge driver 的安装

下载地址: 微软边缘 - 网络驱动程序 (windows.net)

 

 

 

from selenium.webdriver import Edge

# 1.创建浏览器对象
web = Edge()

# 2. 打开一个网址
web.get("https://www.baidu.com")

# 3. 得到标题
print(web.title)

 

  • selenium 切换窗口

 

 

 

 

  • selenium 切换到iframe

什么是iframe:

 HTML 内联框架元素 (<iframe>) 表示嵌套的 browsing  context。它能够将另一个 HTML 页面嵌入到当前页面中。

 

  • selenium 切换到下拉列表 select

 

 

 

 

 

  • selenium 设置无头浏览器(后台运行浏览器)

 

 

 

  • selenium 拿到elements

 

posted @ 2022-10-30 15:16  slowlydance2me  阅读(255)  评论(0编辑  收藏  举报