运行selenium爬虫脚本时遇到关于chrome的问题

在运行selenium爬虫时遇到错误,原因是chrome驱动缺失。通过在.bashrc文件中添加路径并更新环境变量解决了驱动路径问题。然而,脚本仍报错,发现是chrome driver版本与chrome浏览器版本不一致。通过查看chrome版本信息,并从官方源下载对应版本的chromedriver,替换原有驱动,成功解决了问题。

一个使用selenium的爬虫脚本,运行时报错:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable 
needs to be in PATH. Please see 
https://sites.google.com/a/chromium.org/chromedriver/home

这是因为缺少chrome驱动,安装上:

sudo apt-get install chromium-chromedriver

修改~/.bashrc,在最后加上export PATH=$PATH:/usr/lib/chromium-browser/

vim ~/.bashrc
export PATH=$PATH:/usr/lib/chromium-browser/
source ~/.bashrc

运行脚本然后报错:

selenium.common.exceptions.SessionNotCreatedException: Message: session not 
created: This version of ChromeDriver only supports Chrome version 81

因为chromedriver版本与chrome版本不一致导致的,apt-get更新驱动发现更新不了最新版本,所以采用暴力的手法。在chrome导航栏输入chrome://version/,查看安装的chrome版本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值