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这个包无法查找到的原因. 问题显示如下: 可以使用以下方式安装 ...
随机推荐
- Nuxt.js笔记
前置知识 SSR服务器渲染 Vue SSR(server side rendering)服务端渲染 和 Vue SPA(single page application)单页应用 Vue SSR-> ...
- C#中Dictionary的介绍
关键字:C# Dictionary 字典 作者:txw1958原文:http://www.cnblogs.com/txw1958/archive/2012/11/07/csharp-dictionar ...
- 路径规划算法之Bellman-Ford算法
最近由于工作需要一直在研究Bellman-Ford算法,这也是我第一次用C++编写代码. 1.Bellman-Ford算法总结 (1)Bellman-Ford算法计算从源点(起始点)到任意一点的最短路 ...
- spark基础知识(1)
一.大数据架构 并发计算: 并行计算: 很少会说并发计算,一般都是说并行计算,但是并行计算用的是并发技术.并发更偏向于底层.并发通常指的是单机上的并发运行,通过多线程来实现.而并行计算的范围更广,他是 ...
- linux oops调试
参考文章: arm 指令定位错误 https://blog.csdn.net/songcdut/article/details/41383483 linux mips指令学习 https://www. ...
- spring.http.multipart.maxFileSize提示无效报错问题处理
在SpringBoot项目中,配置spring.http.multipart.maxFileSize用于限定最大文件上传大小. 但是,SpringBoot版本不同,关于这一块的配置也不相同. 1.Sp ...
- Image 上传下载Api
1.配置 "UploadConfig": { // 自定义存放位置,无需放到站点内部 "Path": "C:\\Users\\kxy\\Desktop ...
- Django models文件模型变更注意事项(表结构的修改)
表结构的修改 1.表结构修改后,原来表中已存在的数据,就会出现结构混乱,makemigrations更新表的时候就会出错 比如第一次建模型,漏了一个字段,后来补上了.(经常遇到模型字段修改) 重新ma ...
- electron 热更新
试用了下,electron 自带的热更新 并不是特别理想. 想自己处理下载更新文件.刚好看到了网上有一个比较好的处理方式.试了下效果还可以. 使用以下命令将此库包含在项目中: npm install ...
- Flask简介&入门
1 了解框架 Flask作为Web框架,它的作用主要是为了开发Web应用程序.那么我们首先来了解下Web应用程序.Web应用程序 (World Wide Web)诞生最初的目的,是为了利用互联网交流工 ...