python(3.8比较稳定)
官网地址:https://www.python.org/downloads/
华为云地址:https://mirrors.huaweicloud.com/python/
第三方镜像:https://registry.npmmirror.com/binary.html?path=python/
selenium下载:
#安装selenium
pip install selenium
#展示版本
pip show selenium
webdriver驱动器:根据浏览器版本下载
Chrome for Testing availability (googlechromelabs.github.io)
将Chromedriver.exe放置在Chrome浏览器的位置之下
chrome://version/
配置环境变量
安装完验证:
# 导包
from time import sleep
from selenium import webdriver
# 实例化浏览器
driver = webdriver.Chrome()
# 打开网址
driver.get('https://www.baidu.com/')
# 需求
ele = driver.find_element_by_css_selector('#kw')
ele.send_keys('selenium')
sleep(2)
# 清空
ele.clear()
ele.send_keys('selenium')
# 时间轴看效果
sleep(3)
# 关闭页面
driver.quit()