zoukankan      html  css  js  c++  java
  • linux---centos7 安装chromedriver

    1.安装浏览器

    指定yum 源

    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

    安装

    curl https://intoli.com/install-google-chrome.sh | bash

    ldd /opt/google/chrome/chrome | grep "not found"

    安装后,执行:google-chrome-stable --no-sandbox --headless --disable-gpu --screenshot https://www.baidu.com/

    报这个错误?我猜想是没有UI界面的原因,到这里可以判断安装成功。

    2. 安装chromedriver

    下载:https://npm.taobao.org/mirrors/chromedriver/

    unzip 解压

    安装完成

     建立软连接:

    ln -s /opt/google/chromedriver /usr/bin/chromedriver

     3.测试:

    #coding=utf8
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    chrome_options = Options()
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')
    driver = webdriver.Chrome(chrome_options=chrome_options)
    #driver = webdriver.Chrome()
    driver.get("https://www.baidu.com")
    
    print(driver.page_source)
    #driver.quit()

    到这里ok

  • 相关阅读:
    HDU 4801 Pocket Cube
    HDU 5008 Boring String Problem(后缀数组+二分)
    2-Sat问题
    后缀数组
    树形DP
    图论
    SRM 628 DIV2
    组合博弈
    Github使用笔记
    VS2010+OpenCV配置
  • 原文地址:https://www.cnblogs.com/myvic/p/9450134.html
Copyright © 2011-2022 走看看