博客
关于我
CentOS + Selenium+Chrome环境安装
阅读量:364 次
发布时间:2019-03-04

本文共 928 字,大约阅读时间需要 3 分钟。

# 以Chrome为例# 安装seleniumpip3 install selenium# 安装chrome-browserwget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm --no-check-certificate  sudo yum install google-chrome-stable_current_x86_64.rpm# 安装chromedriver:一个用来和chrome交互的接口sudo yum install chromedriver# 编写test.py文件vim test.py

安装这个的时候  google-chrome-stable_current_x86_64 有一个y/d/N 选y

# test.pyfrom selenium import webdriverfrom selenium.webdriver.chrome.options import Optionschrome_options = Options()chrome_options.add_argument('--headless') # 16年之后,chrome给出的解决办法,抢了PhantomJS饭碗chrome_options.add_argument('--disable-gpu')chrome_options.add_argument('--no-sandbox')  # root用户不加这条会无法运行driver = webdriver.Chrome(chrome_options=chrome_options)for i in range(10):    driver.get("https://www.baidu.com/")    print(driver.title)driver.close()# 正常的输出就是10个"百度一下,你就知道"

为毛 要使用chrome_options这个参数呢。。因为centos没有图形化界面  所以只能用无参数来执行。

无参数的好处就是隐形执行。坏处就是需要对协议有更深层的了解。

转载地址:http://uxtr.baihongyu.com/

你可能感兴趣的文章
ng6.1 新特性:滚回到之前的位置
查看>>
nghttp3使用指南
查看>>
Nginx
查看>>
nginx + etcd 动态负载均衡实践(一)—— 组件介绍
查看>>
nginx + etcd 动态负载均衡实践(三)—— 基于nginx-upsync-module实现
查看>>
nginx + etcd 动态负载均衡实践(二)—— 组件安装
查看>>
nginx + etcd 动态负载均衡实践(四)—— 基于confd实现
查看>>
Nginx + Spring Boot 实现负载均衡
查看>>
Nginx + Tomcat + SpringBoot 部署项目
查看>>
Nginx + uWSGI + Flask + Vhost
查看>>
Nginx - Header详解
查看>>
nginx - thinkphp 如何实现url的rewrite
查看>>
Nginx - 反向代理、负载均衡、动静分离、底层原理(案例实战分析)
查看>>
Nginx - 反向代理与负载均衡
查看>>
nginx 1.24.0 安装nginx最新稳定版
查看>>
nginx 301 永久重定向
查看>>
nginx 403 forbidden
查看>>
nginx connect 模块安装以及配置
查看>>
nginx css,js合并插件,淘宝nginx合并js,css插件
查看>>
Nginx gateway集群和动态网关
查看>>