Selenium-快速使用

本文详细介绍Selenium Python库在自动化测试中的应用,包括不同浏览器驱动的安装与配置方法、基本页面操作及元素定位技巧等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

点击查看 selenium-python-关闭与定位操作

点击查看 selenium-python-操作表单元素与切换窗口

点击查看 selenium-python-行为链与cookie操作

点击查看 selenium-python-隐式等待与显示等待

点击查看 selenium-python-设置代理IP操作与WebElement元素 

Selenium获取动态数据

Selenium 相当于一个机器人,可以模拟人类在浏览器上的一些行为,自动处理浏览器的一些行为,比如点击,填充数据,删除cookies等。

不同的driver:

chrome

https://sites.google.com/a/chromium.org/chromedriver/downloads

http://npm.taobao.org/mirrors/chromedriver/

Firefox

https://github.com/mozilla/geckodriver/releases

Edge

https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Safari

https://webkit.org/blog/6900/webdriver-support-in-safari-10/

 

Python-快速使用 

from selenium import webdriver
# 设置Chromedrive的启动路径
driver_path = r'E:\vens\chromedriver\chromedriver.exe'

driver = webdriver.Chrome(executable_path=
driver_path)  # 使用Chrome路径
driver.get("http://www.baidu.com")  # 请求网页

# 通过page_source获取网页源代码
print(driver.page_source)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

pylemon

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值