首先下载依赖
yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts
然后下载安装chrome
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
查看chrome版本号
google-chrome --version
根据版本号下载对应的驱动
https://registry.npmmirror.com/binary.html?path=chromedriver/
wget https://chromedriver.storage.googleapis.com/2.38/chromedriver_linux64.zip
将解压好的文件放在/usr/bin目录下,并且给chromedrive增加可以执行权限
解压
unzip chromedriver_linux64.zip
mv chromedriver /usr/bin/
给予执行权限
chmod +x /usr/bin/chromedriver
运行代码测试
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless') #设置无头浏览器请求模式
options.add_argument("--disable-extensions")
options.add_argument("--disable-gpu")
options.add_argument("--no-sandbox") # linux中不写会报错
driver = webdriver.Chrome(options=options)
driver.get('https://www.baidu.com')
print(driver.page_source)
#######
标签:--,selenium,chromedriver,add,linux,com,options,上面 From: https://www.cnblogs.com/andy0816/p/16810605.html