yum update
yum install Xvfb
yum -install libXfont
yum install xorg-x11-fonts*
执行 xvfb-run 程序即可。
vi /etc/yum.repos.d/google-chrome.repo
写入:
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
yum update
yum install google-chrome-stable
添加软连接
which google-chrome-stable
ln -s 路径 /bin/chrome
查看版本
chrome -version
下载对应驱动
https://sites.google.com/a/chromium.org/chromedriver/home下载chromedriver
添加权限 软连接
chmod +x chromedriver
sudo mv -f chromedriver /usr/local/share/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
pip install selenium
pip install pyvirtualdisplay
options = webdriver.ChromeOptions()
options.add_argument(‘--headless‘)
browser = webdriver.Chrome(chrome_options=options)
from selenium import webdriver
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
options = webdriver.ChromeOptions()
options.add_argument(‘--headless‘)
browser = webdriver.Chrome(chrome_options=options)
browser.get("http://www.baidu.com")
print(browser.page_source)
browser.quit()
display.stop()
转自:https://blog.csdn.net/ZincZhang/article/details/79797847
原文:https://www.cnblogs.com/jp1021/p/12675645.html