centos7.4 64位安装 google-chrome 与 chromedriver 运行 Python selenium 项目
centos7.4 实例

利用 yum 命令安装 google-chrome 超级简单(安装最新版):
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
chromedriver 也下载最新版就好,和Mac 版本一样,我依旧选择这个最新版本:
http://chromedriver.storage.googleapis.com/index.html?path=70.0.3538.16/

Python3.7 之前安装过:
Centos7 环境下 Python2.7 换成 Python3.7 运行 scrapy 应用所遇到的问题记录
然后配置一下,就能跑起来 selenium 项目了,当然该 pip install xxx 安装模块就缺什么安装什么了
# 设置 webdriver 参数
options = webdriver.ChromeOptions()
# 设置谷歌浏览器的一些选项
# proxy 代理 options 选项
options.add_argument(r'--proxy--server=http:\\' + ip)
uas = get_uas()
# 设置user-agent
options.add_argument('user-agent=' + choice(uas))
# 以 headless 方案运行
options.add_argument('--headless')
options.add_argument('--no-sandbox')
# options.add_argument('--disable-dev-shm-usage')
# 禁用图片访问
# prefs = {"profile.managed_default_content_settings.images": 2}
# options.add_experimental_option("prefs", prefs)
如果不配置 # 以 headless 方案运行
会抛出下面异常

[root@iZwz9117d4ssv2v5oe81m3Z selenium_baidu]# python testRun.py
package_util 初始化
testRun.py:: DeprecationWarning: use options instead of chrome_options
driver = webdriver.Chrome(path, chrome_options=options)
Exception in thread Thread-:
Traceback (most recent call last):
File "/usr/python/lib/python3.7/threading.py", line , in _bootstrap_inner
self.run()
File "/usr/python/lib/python3.7/threading.py", line , in run
self._target(*self._args, **self._kwargs)
File "testRun.py", line , in get_url
driver = webdriver.Chrome(path, chrome_options=options)
File "/usr/python/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line , in __init__
desired_capabilities=desired_capabilities)
File "/usr/python/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line , in __init__
self.start_session(capabilities, browser_profile)
File "/usr/python/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line , in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/python/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line , in execute
self.error_handler.check_response(response)
File "/usr/python/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line , in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=70.0.3538.16 (16ed95b41bb05e565b11fb66ac33c660b721f778),platform=Linux 3.10.-693.2..el7.x86_64 x86_64)
selenium 代码正确运行:

centos7.4 64位安装 google-chrome 与 chromedriver 运行 Python selenium 项目的更多相关文章
- centos7.3 64位 安装git
1.安装编译git时需要的包 # yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel # yum ins ...
- centos7.2 64位安装java
1. wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk- ...
- centos7.4 64位安装 git
参考博客:Linux Jenkins配置Git 1. git --version 查看有没有安装 过 git,没有则 继续 2. git 压缩包下载地址:https://mirrors.edge.ke ...
- centos7.4 64位安装 redis-4.0.0
1. 下载 redis 包 链接:https://pan.baidu.com/s/1g1UE_GTreXoD9uOXB7G3HA 提取码:ug8p 2. 安装gcc.ruby .rubygems等环 ...
- Ubuntu 14.04 LTS下安装Google Chrome浏览器
在Ubuntu 14.04下安装Google Chrome浏览器非常简单,只要到Chrome的网站下载Deb安装包并进行安装即可.当然你也可以使用APT软件包管理器来安装Google Chrome浏览 ...
- 在ubuntu下安装google chrome
由于手上有两台电脑,再加上我那个选择困难症加上纠结劲.所以果断把其中一台电脑只装linux系统,另一台电脑只装windows了.免得我老纠结!于是linux便选择了ubuntu. 由于浏览器一直用的是 ...
- ubuntu14.04 64位 安装eclipse
ubuntu14.04 64位 安装eclipse 1 在官网上下载eclipse http://www.eclipse.org/downloads/下载eclipse-jee-luna-SR1-li ...
- Windows 7 64位安装cURL
安装cURL. 1, 下载64位的SSL版cURL,网址: http://curl.download.nextag.com/download/curl-7.21.7-win64-ssl-sspi.zi ...
- ubuntu 14.04 64位安装iNodeClient
ubuntu 14.04 64位安装iNodeClieng(华三校园客服端) http://pan.baidu.com/s/12dpxk ubuntu 14.04 64bit Install H3C ...
随机推荐
- 6月23 Ajax传地址
利用Ajax将图片存入数据库的过程中可能会出现路径乱码或不一致的现象因此要对其进行编码解码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...
- 布局神器 display:flex;
布局神器 display:flex; 2009年,W3C提出了一种新的方案--Flex布局,可以简便.完整.响应式地实现各种页面布局.目前已得到所有现在浏览器的支持. 一.Flex布局是什么? Fle ...
- springboot启动插件
对jsp支持后不再使用启动类启动项目,否则无法支持jsp <plugins> <plugin> <groupId>org.springframework.boot& ...
- Python- - -基础目录
一.Python.pycharm的介绍与安装. 二.变量.整数.字符串.列表.字典.集合. 三.运算符.格式化输出.流程控制语句. 四.break和continue. 五.range.enumerat ...
- python -- while循环,格式化输出,运算符,初识编码
一.while循环 1.语法 while 条件: 循环体(结果) 如果条件为真,则直接执行结果),然后再次判断条件,知道条件为假,停止循环. while True: print('你是谁呢') 退 ...
- easyui 如何为标签动态追加属性实现渲染效果
简述一下在项目遇到的问题,这边有一个需求,选择不同类型,加载不同的div标签(其中属性是否必填是区分类型的关键) html界面是这样的 <div class="grid_1 lbl&q ...
- Android 音视频深入 十五 FFmpeg 推流mp4文件(附源码下载)
源码地址https://github.com/979451341/Rtmp 1.配置RTMP服务器 这个我不多说贴两个博客分别是在mac和windows环境上的,大家跟着弄 MAC搭建RTMP服务器h ...
- eclipse中maven本地库和远程阿里库的配置
很久没有写博客了,最近比较闲将最近学的和遇到的问题做一个备忘 1.eclipse中maven本地库的配置 如果只是下载和安装了maven没有指定maven本地库的位置,maven的默认的本地库在c:/ ...
- jquery mCustomScrollbar 滚动条宽度的设置
一.项目使用 $("#iscroll-1, #tree_box, .work, .item1, .item2, .item3, .item4").mCustomScrollbar( ...
- 剑指Offer 26. 二叉搜索树与双向链表 (二叉搜索树)
题目描述 输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表.要求不能创建任何新的结点,只能调整树中结点指针的指向. 题目地址 https://www.nowcoder.com/practic ...