centos8 安装chromedriver

安装浏览器

1、curl https://intoli.com/install-google-chrome.sh | bash
2、ldd /opt/google/chrome/chrome | grep "not found”
3、google-chrome-stable --no-sandbox --headless --disable-gpu --screenshot https://www.baidu.com

# 查看chrome版本号
google-chrome --version

上这找到对应版本的driver

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

下载下来以后解压,上传到服务器的 /usr/bin 目录
测试脚本

# test.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
 
chrome_options = Options()
chrome_options.add_argument('--headless') 
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')  # root用户不加这条会无法运行
 
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get("https://www.baidu.com/")
print(driver.title)
driver.close()
# 正常输出为"百度一下,你就知道"
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容