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这个包无法查找到的原因. 问题显示如下: 可以使用以下方式安装 ...
随机推荐
- font-family
Font-family: Helvetica, Tahoma, Arial, “Microsoft YaHei”, “微软雅黑”, SimSun, “宋体”, STXihei, “华文细黑”, Hei ...
- E. Vanya and Balloons Codeforces Round #355 (Div. 2)
http://codeforces.com/contest/677/problem/E 题意:有n*n矩形,每个格子有一个值(0.1.2.3),你可以在矩形里画一个十字(‘+’形或‘x’形),十字的四 ...
- jQuery禁用、开启鼠标滚轮事件
1.禁用鼠标滚轮事件 $(document).bind('mousewheel', function(event, delta) {return false;}); 2.开启鼠标滚轮事件,直接解绑事件 ...
- CPM、CPC、CPA、CPS、CPL、CPR 是什么意思 -解析互联网广告术语
CPA CPS CPA/CPS常见的推广方式 CPA和CPSCPA,CPS CPS与CPA CPA.CPSCPA.CPS产品教 CPA CPS什么意思 CPACPS是什么 1. CPM(Cost p ...
- mysql定时器设置开机默认自启动
1).查询mysql安装位置:show variables like "%char%"; 2).查询定时器是否开启: -查询定时器状态:show VARIABLES LIKE '% ...
- 软件测试之实际工作工作方式001--log4
软件测试之实际工作工作方式001--log4 Dotest软件测试-董浩整理 领导安排任务后: 1)首先要确认理解:是指的某工作吗?具体有什么要求吗?时间截止到什么时候? 解析: a.万一 ...
- Android OS的image文件组成
Android OS由以下image文件组成: 1)Bootloader ---在设备启动时开始加载Boot image 2)Boot image ---Kernel 和 RAMdisk 3)Syst ...
- windows2012服务器中安装php7+mysql5.7+apache2.4环境
1.下载安装apache.2.4 https://home.apache.org/~steffenal/VC14/binaries/httpd-2.4.38-win64-VC14.zip 解压到d盘的 ...
- Debug Dump file
dump file is a snapshot of the processs memeory. to debug it, we need use its corresponding executiv ...
- Java基础——Instanceof 运算符
Instanceof 运算符 java 中的instanceof 运算符是用来在运行时指出对象是否为特定类的一个实例 instanceof运算返回值:boolean类型 用法 boolean resu ...