selenium学习笔记

一.搭建环境

1.安装chrome

bash 复制代码
#下载chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

#安装chrome
apt --fix-broken install ./google-chrome-stable_current_amd64.deb

2.安装chromedriver

首先先查看版本:google-chrome --version

前往Chrome for Testing availability

下载对应版本号的driver

bash 复制代码
#下载
wget https://storage.googleapis.com/chrome-for-testing-public/123.0.6312.86/linux64/chrome-linux64.zip


#执行
unzip chromedriver-linux64.zip
cd chromedriver-linux64
mv chromedriver /usr/bin

3.核对版本号是否一致

bash 复制代码
#
google-chrome --version
#
chromedriver --version

4.调试

python 复制代码
from selenium import webdriver                                        
 
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')


driver = webdriver.Chrome(options=chrome_options)
url = "https://baidu.com"
driver.get(url)
print(driver.title)
相关推荐
楼田莉子1 小时前
MySQL数据库:MySQL的数据类型
数据库·学习·mysql
小陈phd1 小时前
系统架构师学习笔记(三)——计算机体系结构之存储系统
笔记·学习·系统架构
Rsun045512 小时前
AI智能体学习路线
人工智能·学习
feasibility.2 小时前
SSH Agent Forwarding 与 tmux 排障笔记
linux·运维·服务器·经验分享·笔记·ssh
charlie1145141912 小时前
通用GUI编程技术——Win32 原生编程实战(十六)——Visual Studio 资源编辑器使用指南
开发语言·c++·ide·学习·gui·visual studio·win32
知识分享小能手2 小时前
MongoDB入门学习教程,从入门到精通,MongoDB查询(4)
数据库·学习·mongodb
weixin_409383122 小时前
godot等轴视角tilemaplayer的学习 isocheric的素材xy大小怎么调
学习·游戏引擎·godot
2201_754864783 小时前
学习日记(2026年3月23日)
学习
dulu~dulu4 小时前
算法---寻找和为K的子数组
笔记·python·算法·leetcode
W起名有点难4 小时前
【Salesforce学习】创建Object笔记
笔记