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()
相关推荐
Ronin305几秒前
【Linux系统】vim编辑器 | 编译器gcc/g++ | make/Makefile
linux·运维·服务器·ubuntu·编辑器·vim
Bruce_Liuxiaowei23 分钟前
Netstat高级分析工具:Windows与Linux双系统兼容的精准筛查利器
linux·运维·网络·windows·安全
yt9483226 分钟前
C#实现CAN通讯接口
java·linux·前端
linux修理工43 分钟前
n1 armbian 安装桌面环境并启用xrdp远程登录
linux·服务器·数据库
花小璇学linux1 小时前
imx6ull-裸机学习实验1——汇编LED灯实验
linux·汇编·imx6ull·arm裸机开发
Brookty1 小时前
【操作系统】进程(二)内存管理、通信
java·linux·服务器·网络·学习·java-ee·操作系统
GuokLiu2 小时前
250708-通过两块硬盘拷贝DeepSeek两个满血版模型的bash脚本
开发语言·chrome·bash
sanggou5 小时前
Linux批量执行工具脚本使用指南:一键运行多个release-dev.sh脚本
linux·bash
牧以南歌〆10 小时前
在Ubuntu主机中修改ARM Linux开发板的根文件系统
linux·arm开发·驱动开发·ubuntu
夜月yeyue11 小时前
设计模式分析
linux·c++·stm32·单片机·嵌入式硬件