<解决方法>Centos安装使用Chromedriver

时间:2023-03-08 20:21:58

一、安装Chrome

我安装好Centos系统后,就在网上去找Chrome浏览器的安装方法,使用过yum,rpm都安装不上,会报错,然后询问公司的运维,他给我了个包,然后使用:yum localinstall 包名

就安装成功了,安装的路径默认是/opt/google/chrome/

yum localinstall  安装rpm会自动的安装依赖,不需要单独的安装依赖

下面有对应的版本可用,亲测了:

Chrome版本:68.0.3440.106

Chromedriver版本:2.41

下载地址:

https://pan.baidu.com/s/1S8YBVQpOhzaceF9NsixU7A

二、下载Chromedriver

所有版本下载地址:

http://chromedriver.storage.googleapis.com/index.html

三、使用Chromedriver

借鉴地址:https://blog.****.net/blueheart20/article/details/81566903

我用的是python的selenium框架来使用Chromedriver。

直接driver.Chrome()是会报错: Chrome failed to start: exited abnormally,需要使用带参数的启动方法:

 chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')

加上之后就运行成功了

备注:

一、解决 Requires: libc.so.6(GLIBC_2.14)(64bit):

https://blog.****.net/zhou_shaowei/article/details/76066934

https://blog.****.net/clirus/article/details/62425498

https://blog.****.net/changcsw/article/details/79761620

二、Chrome对应的driver版本

三、运行chromedriver报错

报错:[1570616532.097][SEVERE]: bind() returned an error, errno=99: Cannot assign requested address (99)

解决方法:运行时,添加参数:--whitelisted-ips  就不会有这个错误

[root@sonny ]# chromedriver --whitelisted-ips

参考:https://*.com/questions/55844788/how-to-fix-severe-bind-failed-cannot-assign-requested-address-99-while