系统教程
您现在的位置是:首页>服务器系统>Ubuntu系统内容

Ubuntu系统下selenium报WebDriverException错误

时间:2018-04-25 出处:未知复制分享人气(次) 【

众所周知,Python是爬虫的利器,最近在做一爬虫,爬取网易云音乐热门歌曲的热门评论,发现网站是js的,所以想用selenium模拟浏览器渲染js后再获取相应的内容。
from selenium import webdriver
browser = webdriver.Chrome()
 
实例化谷歌浏览器对象时报以下错误:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
 
打开上面报错信息提示的链接chromedriver(https://sites.google.com/a/chromium.org/chromedriver/home),根据自己的系统下载最新的chromedriver(下载列表页:https://chromedriver.storage.googleapis.com/index.html?path=2.28/)
Ubuntu系统下selenium报WebDriverException错误
 
解压刚下载的zip包,把可执行文件chromedriver复制到/usr/bin目录下
sudo cp chromedriver /usr/bin
 
升级谷歌浏览器到最新(# Ubuntu系统)
sudo apt-get –upgrade install chromium-browser
 
这样问题就解决了。
    最新资讯
    热门内容
    小米移动电源能为iPad mini充几次电