Linux下安装chrome和chromedriver
安装chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm yum install ./google-chrome-stable_current_x86_64.rpm yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts
安装chromedriver
wget http://npm.taobao.org/mirrors/chromedriver/2.41/chromedriver_linux64.zip unzip chromedriver_linux64.zip mv chromedriver /usr/bin/ chmod +x /usr/bin/chromedriver
Python脚本快速测试
from selenium.webdriver.chrome.options import Options from selenium import webdriver chrome_options = Options() chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage') chrome_options.add_argument('blink-settings=imagesEnabled=false') chrome_options.add_argument('--headless') driver = webdriver.Chrome(chrome_options=chrome_options) driver.get('https://www.baidu.com') print driver.page_source print driver.title