在centos7 上安装chrome+chromedriver

博客介绍了在Linux系统中查看谷歌浏览器版本的方法,即使用命令 /usr/bin/google-chrome -version ,并给出了信息转载来源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装chrome
首先安装google的epel源
vi /etc/yum.repos.d/google.repo
[google]
name=Google-x86_64
baseurl=http://dl.google.com/linux/rpm/stable/x86_64 

enabled=1
gpgcheck=0
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub 


yum update , 然后yum install google-chrome-stable
chromedriver下载
https://npm.taobao.org/mirrors/chromedriver/ 

 将下载的chromedriver 放到脚本同级目录调用
3.安装selenium,使用是的python3
pip3 install selenium 
默认centos 7已经安装了python2,指定python3安装selenium可以指定bin目录下的pip来安装
代码测试:
以登陆西部数码为例
#!/usr/local/python3/bin/python3

from selenium import webdriver
from selenium.webdriver.chrome.options import Options



chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
url="https://www.west.cn/login.asp 

"
brower=webdriver.Chrome(executable_path="./chromedriver", chrome_options=chrome_options)
brower.get(url)
name=brower.find_element_by_xpath('//input[@name="u_name"]')
name.send_keys('******')
mima=brower.find_element_by_xpath('//input[@name="u_password"]')
mima.send_keys('******')
button=brower.find_element_by_xpath('//button[@class="g-commo"]')
button.click()
brower.refresh()
brower.get("https://www.west.cn/Manager/")
brower.quit()

 linux查看谷歌版本:/usr/bin/google-chrome -version

转载于:https://www.cnblogs.com/fh-fendou/p/10824239.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值