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()
相关推荐
wuminyu7 小时前
Kafka中sendfile与mmap实现机制解析
java·linux·c语言·jvm·c++
新时代牛马7 小时前
嵌入式网络完整篇:从LwIP/以太网驱动到 Linux netdev 与排障
linux·网络·php
猿与禅7 小时前
Linux(Ubuntu)入门到实战:系统管理、常用命令与权限体系完整指南
linux·ubuntu·apt·进程管理·系统运维·用户权限·vi/vim
前端世界8 小时前
Linux服务器实战:NTP时间同步、SELinux权限与rsyslog日志管理,一次搞懂三大运维问题
linux·运维·服务器
Android系统攻城狮8 小时前
Linux Gstreamer深度解析之gst_audio_converter_new调用流程与实战(二十)
linux·运维·服务器·gstreamer音视频·音视频进阶
H_oRIZoN_13 小时前
Linux入门DAY41(51 单片机 串口与通信协议)
linux·运维·单片机
GeW14 小时前
RHCE备考别瞎学!按这个计划走,30天提高通过率,快速拿证
linux
Escalating_xu15 小时前
【System V 信号量】从 P/V 原语到 Builder 封装:写出可控、可清理的进程互斥组件
java·linux·开发语言·jvm
傲世仙尊15 小时前
System V 进程间通信详解:共享内存、消息队列与信号量(CSDN博客)
linux·开发语言·c++
minhuan15 小时前
大模型前端感知层工程实践:基于Headless Chrome验证AI静默监听人脸动静检测逻辑27.2
chrome·大模型应用·大模型前端感知层工程·headless chrome·ai静默监听人脸动静检测