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()
相关推荐
盛世隐者13 分钟前
【Linux】定制Linux系统
linux·运维·服务器
-Excalibur-2 小时前
形象解释关于TCP/IP模型——层层封装MAC数据帧的过程
linux·c语言·网络·笔记·单片机·网络协议·tcp/ip
小跌—2 小时前
Linux:数据链路层
linux·网络
用户31187945592182 小时前
Fedora 37 安装 libicu-71.1-2.fc37.x86_64.rpm 教程(命令行步骤)
linux
搬砖的小码农_Sky2 小时前
Linux(Ubuntu)操作系统下文件的解压
linux·ubuntu
景彡先生3 小时前
Python函数定义与调用全解析:从基础语法到实战技巧
linux·开发语言·python
Lxt.星翊3 小时前
MySQL(安装和卸载、数据库存储原理图)
linux·运维·windows
m***记3 小时前
Python字符串操作:如何判断子串是否存在
linux·服务器·python
添砖java‘’3 小时前
探索Linux进程:从理论到实践
linux·进程
JustNow_Man4 小时前
Cline中模型识别任务与clinerules相关性的实现逻辑
linux·运维·ubuntu