Linux + selenium + chromedriver

1. 安装selenium模块

pip3 install selenium

2. 安装Chromedriver

2.1 查看当前浏览器版本

google-chrome --version

注意:深度linux中chrome路径为 /opt/apps/cn.google.chrome/files/google-chrome

2.2 Chromedriver下载对应版本解压

2.2 Chromedriver下载对应版本解压
    下载地址    http://chromedriver.storage.googleapis.com/index.html

2.3 添加执行权限,把他放到/usr/bin目录下(Windows是放到Python的安装目录)

chmod a+x chromedriver
mv chromedriver /usr/bin/

3. 测试

能打开浏览器就行

    from selenium import webdriver
    driver = webdriver.Chrome()

报错:深度linux中找不到chrome程序

解决:将chrome程序连接到 /usr/bin/

cd /usr/bin/
ln -s /opt/apps/cn.google.chrome/files/google-chrome

 

posted @ 2023-03-03 15:22  ranh  阅读(604)  评论(0编辑  收藏  举报