zoukankan      html  css  js  c++  java
  • 转 ubuntu 安装chrome 和chromedriver

    ubuntu 安装chrome 和chromedriver

    1. chromedriver 下载地址:  https://npm.taobao.org/mirrors/chromedriver

    在这里找到对应的驱动

    2. 安装谷歌浏览器

    2.1 安装依赖 

    apt-get install libxss1 libappindicator1 libindicator7

    2.2 下载Chrome安装包

    wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

    2.3 安装

    sudo dpkg -i google-chrome*.deb
    sudo apt-get install -f

    3. 安装chromedriver 

    找到和浏览器对应的驱动

    3.1 安装依赖

    apt-get install unzip

    unzip chromedriver_linux64.zip

    mv -f chromedriver /usr/local/share/chromedriver

    3.2 安装

    #建立软连接
    ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver

    4. 测试(root用户下可用如下脚本)

    复制代码
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    
    options = Options()
    options.add_argument('--headless')
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-dev-shm-usage')
    driver = webdriver.Chrome(executable_path="/usr/local/bin/chromedriver",
                              chrome_options=options)
    print("======")
    driver.get('https://www.cnblogs.com/myvic/')
    print(driver.title)
    print('------------')
    driver.quit()
    复制代码
  • 相关阅读:
    Bootstrap 4 网格的基本结构
    Js 框架之Vue .JS学习记录 ① 与Vue 初识
    ASP.NET 发送邮件 SMTP
    c# 多线程简化
    ASP.NET Razor
    ASP.NET MVC 简单介绍①
    握手7
    握手6
    握手5
    握手4
  • 原文地址:https://www.cnblogs.com/python-xiakaibi/p/13050434.html
Copyright © 2011-2022 走看看