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()
相关推荐
点亮一颗LED(从入门到放弃)20 小时前
字符设备驱动(5)
linux·运维·服务器
知识分享小能手21 小时前
CentOS Stream 9入门学习教程,从入门到精通,Linux日志分析工具及应用 —语法详解与实战案例(17)
linux·学习·centos
ZXF_H21 小时前
Linux tcpdump抓包实践(以http为例)
linux·http·wireshark·tcpdump
悄悄敲敲敲21 小时前
Linux:信号(二)
linux·操作系统·信号
Felven21 小时前
飞腾D2000 GPIO中断调试
linux·gpio·中断·d2000
喵了meme1 天前
Linux学习日记21:读写锁
linux·c语言·学习
^乘风破浪^1 天前
Ubuntu部署Xingrin(星环)企业级漏洞扫描与资产管理平台
linux·运维·ubuntu
Lueeee.1 天前
内核模块符号的导出
linux·运维·服务器
C语言魔术师1 天前
【linux】linux进程概念(四)(环境变量)
linux·运维·服务器
松涛和鸣1 天前
DAY32 Linux Thread Programming
linux·运维·数据库·算法·list