1、selenium 使用
① 导包
from selenium import webdrive
② 实例化浏览器对象
browser = webdrive.Chrome(’./chromedriver.exe’)
③ 获取要查找的对象id
login = browser.find_selenium_by_id(‘获取的login页id’)
④ 进行点击/发送消息操作
点击: login.click()
发送消息: login.send_keys( ‘发送的内容 ’ )
清除: login.clear()
退出: login.quit()
2、selenium 安装:
①浏览器 首选 谷歌 下载驱动器版本 在谷歌设置中看版本,前三位必须一样
(下载的网址:http://chromedriver.storage.googleapis.com/index.html
②pip install selenimum
3、谷歌无头浏览器
from selenium import webdrive
from selenium.webdrive.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument(’…headless’)
chrome_options.add_argument(’…disable-gpu’)
browser = webdrive.Chrome(chrome_options = chrome_options)
selenium 的应用
最新推荐文章于 2023-09-22 13:40:31 发布