centos配置chrome+selenium
参考资料
https://blog.csdn.net/wkb342814892/article/details/81591394
1. 安装chrome-browser
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm --no-check-certificate sudo yum install google-chrome-stable_current_x86_64.rpm
2. 安装chromedriver:一个用来和chrome交互的接口
yum install chromedriver
3. 安装selenium
pip install selenium
测试案例
from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument('--headless') # 16年之后,chrome给出的解决办法,抢了PhantomJS饭碗 chrome_options.add_argument('--disable-gpu') chrome_options.add_argument('--no-sandbox') # root用户不加这条会无法运行 driver = webdriver.Chrome(chrome_options=chrome_options) for i in range(10): driver.get("https://www.baidu.com/") print(driver.title) driver.close() # 正常的输出就是10个"百度一下,你就知道"