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()
相关推荐
_Voosk12 分钟前
FreeBSD 使用代理运行命令
linux·运维·freebsd
G_dou_44 分钟前
Linux 搭建 Rust 开发环境:从 rustup 安装到 Cargo 镜像
linux·rust
bsauce2 小时前
【kernel exploit】CVE-2026-23271 perf_event竞态UAF漏洞-ROP提权
linux·linux内核·内核漏洞·内核漏洞利用
Hehuyi_In2 小时前
从优雅到爆烈 —— Linux全力回收内存的一生
linux·内核·内存·memory·回收
杨充3 小时前
1.1 数据编码设计原理
linux·运维·网络·底层原理·数据编码
fan_music3 小时前
Linux I/O
linux
Java小白笔记3 小时前
Linux 手动部署 Oracle JDK 17 完全指南
java·linux·oracle
慵懒的猫mi4 小时前
deepin 25部署x11vnc+xrdp,实现vnc和mstsc双重访问
linux·windows·开源软件·deepin
剑神一笑5 小时前
Linux lsof 命令深度解析:从文件描述符到进程追踪
linux·运维·php
andlbds5 小时前
解决Ubuntu20.04进入系统卡死在厂商Logo界面问题
linux·ubuntu