centos 7 上如何安装chrome 和chrome-driver

centos 7 上如何安装chrome 和chrome-driver

查找自己的服务器是什么系统

bash 复制代码
cat /etc/os-release

这里以centos linux 7为例

下载google-chrome安装包

bash 复制代码
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

安装chrome

bash 复制代码
sudo yum localinstall google-chrome-stable_current_x86_64.rpm 

最后显示complete就表示安装完成了

查看安装版本

bash 复制代码
google-chrome --version 

安装selenium

bash 复制代码
pip install selenium 

用于后续相关代码,方便进行测试

安装chrome-driver

bash 复制代码
 sudo yum install chromedriver 

使用which 查找chromedriver 被安装的位置,将其放到/usr/bin/ 目录下,which找不到的话,可以用下面的命令:

bash 复制代码
sudo find / -name chromedriver

测试相关python代码

bash 复制代码
from selenium import webdriver 
from selenium import webdriver as web
from selenium.webdriver.common.by import By
import time
import os
import urllib
from selenium.webdriver.chrome.service import Service      
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
options = web.ChromeOptions()
options.add_argument('--ignore-certificate-errors-spki-list')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_argument('--headless')  
# Enter path of chromedriver executable file
s = Service('/usr/bin/chromedriver')    
driver = webdriver.Chrome(options=options,service=s)   

wait = WebDriverWait(driver,5)
driver.get("https://www.baidu.com")
driver.quit()
相关推荐
xiaobangsky20 小时前
Linux SMB/CIFS 网络挂载配置指南
linux·运维·网络
wang090720 小时前
Linux性能优化之内存管理基础知识
java·linux·性能优化
杰 .20 小时前
闲暇时刻对LinuxOS的部分理解(一)
linux·服务器
摩斯电码21 小时前
深入 perf 第二版(二):用原始事件编号解锁 CPU 的隐藏指标
linux·性能优化
代码中介商21 小时前
Linux 基础命令完全指南:从文件操作到进程管理
linux·运维·服务器
思麟呀21 小时前
应用层协议HTTP
linux·服务器·网络·c++·网络协议·http
一个人旅程~21 小时前
linuxmint如何使用iphone手机上网以及如何管理iphone手机的照片和文件?需要下载哪些基础包和依赖?
linux·windows·经验分享·电脑
异步的告白21 小时前
链接脚本SECTIONS逐行深度解析
linux·开发语言
南境十里·墨染春水1 天前
linux学习进展 信号
linux·服务器·学习
SiYuanFeng1 天前
一展使用gpt-5-mini和gemini-3.1-flash-image-preview-0.5k的运行demo代码
linux·python·gpt