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

      

  • 相关阅读:
    三级联动(在YII框架中)
    用composer安装Yii
    在apache中设置访问目录后进入的默认页面为index.php
    php mb_convert_encoding的使用
    采集数据和memchche的存储使用,分页展示
    php操作Memcache
    前端页面卡顿?或是DOM操作惹的祸,需优化代码
    windows mongodb 安装
    浅谈WebSocket
    使用Spring MVC HandlerExceptionResolver处理异常
  • 原文地址:https://www.cnblogs.com/royfans/p/14172613.html
Copyright © 2011-2022 走看看