centos7上PhantomJS 过期之后改用Chrome时填的坑
突然有个自动化需求所以准备使用模拟点击的方法,
在使用之前的PhantomJS时,报错
UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome ……
这时候的方法就是换到chrome了,如果你没装过,那么可以按照这里的方法去安装,如果已经安装了,也建议按照这里的方法去排查可能出现的问题,
For Linux
- Check you have installed latest version of chrome brwoser->
chromium-browser -version - If not, install latest version of chrome
sudo apt-get install chromium-browser - get appropriate version of chrome driver from here
- Unzip the chromedriver.zip
- Move the file to
/usr/bindirectorysudo mv chromedriver /usr/bin - Goto
/usr/bindirectorycd /usr/bin - Now, you would need to run something like
sudo chmod a+x chromedriverto mark it executable. finally you can execute the code.
from selenium import webdriver driver = webdriver.Chrome()
driver.get("http://www.google.com")
print driver.page_source.encode('utf-8')
driver.quit()
display.stop()
这样只会就应该可以用了,
如果还报错,selenium.common.exceptions.WebDriverException: Message: '' executable may have wrong permissions.
那极有可能是你没把执行路径添加到path,或者添加的路径不完整,全路径应该是包含chromedriver这个文件名的,不能只写到它所在的文件夹,
eg,
chrome_path = '/usr/bin/chromedriver'
这样就可以了,下面是测试代码,正常执行的,
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')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-extensions') chrome_path = '/usr/bin/chromedriver'
driver = webdriver.Chrome(executable_path=chrome_path, chrome_options=chrome_options) driver.get("https://cnblogs.com/")
centos7上PhantomJS 过期之后改用Chrome时填的坑的更多相关文章
- 在Centos7上安装Python+Selenium+Chrome+Chromedriver
1.下载Chrome 上一篇文章已经演示过了Python+Selenium+Firefox+Geckodriver安装步骤并通过自动化脚本打开百度 因此当前只需要安装Chrome和Chromedriv ...
- 在 CentOS7 上部署 zookeeper 服务
在 CentOS7 上部署 zookeeper 服务 1 用 SecureCRT 或 XShell 等 Linux 客户端工具连接至 CentOS7 服务器: 2 进入到 /usr/local/too ...
- 在 CentOS7 上安装 MySQL5.7
在 CentOS7 上安装 MySQL5.7 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建 ...
- 在CentOS7上通过RPM安装实现LAMP+phpMyAdmin过程全记录
在CentOS7上通过RPM安装实现LAMP+phpMyAdmin过程全记录 时间:2017年9月20日 一.软件环境: IP:192.168.1.71 Hostname:centos73-2.sur ...
- .Net Core在Centos7上初体验
本文主要内容是简单介绍如何在centos7上开发.Net Core项目,在此之前我们首先了解下.Net Core的基本特性. 1 .Net Core和.Net FrameWork的异同 1.1 .Ne ...
- 在阿里云ECS CentOS7上部署基于MongoDB+Node.js的博客
前言:这是一篇教你如何在阿里云的ECS CentOS 7服务器上搭建一个个人博客的教程,教程比较基础,笔者尽可能比较详细的把每一步都罗列下来,包括所需软件的下载安装和域名的绑定,笔者在此之前对Linu ...
- Centos7上安装docker (转)
Centos7上安装docker Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE. 社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如 ...
- springBoot2.0+redis+fastJson+自定义注解实现方法上添加过期时间
springBoot2.0集成redis实例 一.首先引入项目依赖的maven jar包,主要包括 spring-boot-starter-data-redis包,这个再springBoot2.0之前 ...
- 解决centos7上system tools - setting无法打开的问题
今天在centos7上安装中文输入法时,遇到system tools - setting无法打开的问题. 最后定位时libwbclient这个包无法查找到的原因. 问题显示如下: 可以使用以下方式安装 ...
随机推荐
- 题解 P3871 【[TJOI2010]中位数】
orz各位大佬,题解太强了,主席树,堆,线段树,splay,还有暴力,太巨了.所以我用的是fhq treap(好像更高级).算了. 反正都是平衡树,这道题就是动态求中位数,不会做的同学可以先做弱化版P ...
- cmd切换代码页,切换字体,cmd不能输入中文
cmd终端切换编码:437:美国英语.936:中文gbk编码.65001:UTF8 小知识: 如果cmd不能调用中文输入法,也就是不能输入中文,是因为目前激活的代码页不是936 使用 chcp 936 ...
- PLSQL Developer导入dmp文件,一闪而过
在导入数据的时候,一闪而过,也没有任何报错信息. 在环境变量里添加ORACLE_HOME=D:\app\product\11.2.0\dbhome_1就行,此路径是指oracle安装路径.我是用这种方 ...
- will not be managed by Spring/ [managed: 15; max: 15]
检查事务配置 检查 mybatis 配置文件扫描路径是否正确 <!-- 自动扫描 --> <context:component-scan base-package="com ...
- Spring ES
elasticsearchTemplate 和 ElasticsearchRepository JPA中有个ElasticsearchRepository可以做Elasticsearch的相关增删改查 ...
- oracle 表所占空间统计
1.通过查询dba_segments Select owner,segment_name,sum(bytes)/1024/1024 as MB from dba_segments group by o ...
- 「JavaScript面向对象编程指南」原型
在 JS 中,函数本身也是一个包含了方法(如apply和call)和属性(如length和constructor)的对象,而prototype也是函数对象的一个属性 function f(){} f. ...
- AXI4 STREAM DATA FIFO
参考:http://www.xilinx.com/support/documentation/ip_documentation/axis_infrastructure_ip_suite/v1_1/pg ...
- day16——函数式编程和内置函数
编程的方法论 面向过程:找到问题的 函数式:不可变.不用变量保存状态.不修改变量 面向对象: 高阶函数: 满足俩个特性任意一个即为高阶函数 1.函数的传入参数是一个函数名 2.函数的返回值是一个函数名 ...
- PostCSS 实战
专题截图: 项目截图: 目录说明: dest/ 发布代码文件夹: src/ 预编译代码文件夹; node_modules node 插件; gulpfile.js ...