下载google
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
查看google版本
google-chrome --version
安装必要的库
yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts
安装chromedriver
  • 在这个里面找你的对应的版本:https://registry.npmmirror.com/binary.html?path=chromedriver/

    wget https://chromedriver.storage.googleapis.com/版本/chromedriver_linux64.zip
    
  • 装好之后就地解压:

    unzip chromedriver_linux64.zip
    
  • 然后将解压的chromedriver移动到 /usr/bin目录下:

    mv chromedriver /usr/bin/
    
  • 给与执行权限:

    chmod +x /usr/bin/chromedriver
    
  • 检查chromedriver版本:

    chromedriver -version
    

使用

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(chrome_options=chrome_options)

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐