yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts
google-chrome --no-sandbox
(1)查看版本号
google-chrome --version
(2)去淘宝源找寻对应的文件
http://npm.taobao.org/mirrors/chromedriver/
或者
https://registry.npmmirror.com/binary.html?path=chromedriver/
或
http://chromedriver.storage.googleapis.com/index.html
(3)找到后,下载
wget http://npm.taobao.org/mirrors/chromedriver/90.0.4430.24/chromedriver_linux64.zip
(4)解压,赋权
unzip chromedriver_linux64.zip
mv chromedriver /usr/bin/ chome安装目录
cd /usr/bin
chmod +x /usr/bin/chromedriver
查看chromedriver版本号
chromedriver --version
ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865@{#442})
(5)验证
python3
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--headless')
browser = webdriver.Chrome(options=chrome_options)
'''
其他提高性能参数
'''
chrome_options.add_argument('blink-settings=imagesEnabled=false')
chrome_options.add_argument('--disable-gpu')
# “–no-sandbox”参数是让Chrome在root权限下跑
# “–headless”参数是不用打开图形界面