zoukankan      html  css  js  c++  java
  • Linux 运行selenium

     

    1、进入google-chrome官网下载chrome安装包                        

        官网地址:https://www.google.cn/chrome/

        选择要下载的安装包

     2、安装Chrome

    rpm -ivh google-chrome-stable_current_x86_64.rpm
    

     如果报错如下信心:

    error: Failed dependencies:
    	liberation-fonts is needed by google-chrome-stable-87.0.4280.88-1.x86_64
    	libvulkan.so.1()(64bit) is needed by google-chrome-stable-87.0.4280.88-1.x86_64
    

      则:

    yum install liberation-fonts libvulkan.so.1*
    

     3、安装成功

     4、安装 selenium

    下载python3源码
    
    wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
    
    tar  xf Python-3.7.5.tgz ./
    cd Python-3.7.5
    编译
    
    ./configure --prefix=/usr/local/python3
    make&& make install
    
    ln -s /usr/local/python3/bin/python3 /usr/bin/python3
    ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
    
    pip3 install selenium
    pip3 install helium
    

    5、下载chrome dirver,然后放置到/usr/bin的目录下

    http://chromedriver.storage.googleapis.com/index.html

    6、运行demo

    #conding=utf-8
    from selenium import webdriver
    from helium import *
    
    
    option = webdriver.ChromeOptions()
    #option.add_argument('headless')
    option.add_argument('no-sandbox')
    option.add_argument('disable-dev-shm-usage')
    option.add_experimental_option('useAutomationExtension', False)
    option.add_experimental_option('excludeSwitches', ['enable-automation'])
    browser = webdriver.Chrome(chrome_options=option)
    
    browser.get('http://www.baidu.com/')
    print(browser.title)
    set_driver(browser)
    browser.quit()
    

      

  • 相关阅读:
    Redis配置文件详解
    Redis基本操作-20150608
    Redis操作命令
    JedisPoolConfig配置
    jedis提供的功能
    配置Redis主从复制
    python数组查找算法---bisect二分查找插入
    python赋值和拷贝----一切皆对象,参数皆引用
    xml 解析 python
    进阶中级程序员需要做的事
  • 原文地址:https://www.cnblogs.com/royfans/p/14172613.html
Copyright © 2011-2022 走看看