zoukankan      html  css  js  c++  java
  • 在Linux中使用selenium(环境部署)

     

     
    1、安装chrome
    用下面的命令安装Google Chrome
    yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
    也可以先下载至本地,然后安装
    wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
    yum install ./google-chrome-stable_current_x86_64.rpm
     
    安装必要的库
    yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts
     
    2、安装 chromedriver(末尾附chrome和chromedriver的对应版本)
     
    淘宝源(推荐)
    wget http://npm.taobao.org/mirrors/chromedriver/2.41/chromedriver_linux64.zip
     
    将下载的文件解压,放在如下位置
    unzip chromedriver_linux64.zip
    mv chromedriver /usr/bin/
    给予执行权限
    chmod +x /usr/bin/chromedriver
     
    3、运行代码,查看是否成功(python下)linunx格式必须是这样
    from selenium import webdriver
    driver = webdriver.Chrome()
    ch_options = Options()
    ch_options.add_argument("--headless")  # => 为Chrome配置无头模式
    ch_options.add_argument('--no-sandbox')
    ch_options.add_argument('--disable-gpu')
    ch_options.add_argument('--disable-dev-shm-usage')
    
    # # 在启动浏览器时加入配置
    browser = webdriver.Chrome(chrome_options=ch_options)
    
    
    url = "https://www.huobi.me/zh-cn/markets/"
    url = "https://www.huobi.me/zh-cn/markets/"
    browser.get(url)
    browser.implicitly_wait(10)
    print(browser.page_source)
     
  • 相关阅读:
    删除目录软链接注意事项
    使用Dnsmasq搭建本地dns服务器上网
    在CentOS 7 上安装广告服务器 Revive Adserver
    CentOS6 Squid代理服务器的安装与配置
    CentOS6 PXE+Kickstart无人值守安装
    Redis的初步安装
    创建交互式shell脚本对话框
    C 捕获 lua 异常错误
    iic 之24C256存储器 及PCF8563
    汉字的编码与字模点阵小结
  • 原文地址:https://www.cnblogs.com/wukai66/p/13020362.html
Copyright © 2011-2022 走看看