selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

linux—centos7 安装chrome,chromedriver
1.安装浏览器

指定yum 源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

安装

curl https://intoli.com/install-google-chrome.sh | bash

ldd /opt/google/chrome/chrome | grep “not found”

安装后,执行:google-chrome-stable --no-sandbox --headless --disable-gpu --screenshot https://www.baidu.com/

报这个错误?我猜想是没有UI界面的原因,到这里可以判断安装成功。

  1. 安装chromedriver

下载:https://npm.taobao.org/mirrors/chromedriver/

unzip 解压

安装完成

建立软连接:

ln -s /opt/google/chromedriver /usr/bin/chromedriver

3.测试:

复制代码
#coding=utf8
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’)
driver = webdriver.Chrome(chrome_options=chrome_options)
#driver = webdriver.Chrome()
driver.get(“https://www.baidu.com”)

print(driver.page_source)
#driver.quit()
复制代码
到这里ok

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值