一个使用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版本

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

被折叠的 条评论
为什么被折叠?



