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 项目的更多相关文章

  1. centos7.3 64位 安装git

    1.安装编译git时需要的包 # yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel # yum ins ...

  2. centos7.2 64位安装java

    1.  wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk- ...

  3. centos7.4 64位安装 git

    参考博客:Linux Jenkins配置Git 1. git --version 查看有没有安装 过 git,没有则 继续 2. git 压缩包下载地址:https://mirrors.edge.ke ...

  4. centos7.4 64位安装 redis-4.0.0

    1.  下载 redis 包 链接:https://pan.baidu.com/s/1g1UE_GTreXoD9uOXB7G3HA 提取码:ug8p 2. 安装gcc.ruby .rubygems等环 ...

  5. Ubuntu 14.04 LTS下安装Google Chrome浏览器

    在Ubuntu 14.04下安装Google Chrome浏览器非常简单,只要到Chrome的网站下载Deb安装包并进行安装即可.当然你也可以使用APT软件包管理器来安装Google Chrome浏览 ...

  6. 在ubuntu下安装google chrome

    由于手上有两台电脑,再加上我那个选择困难症加上纠结劲.所以果断把其中一台电脑只装linux系统,另一台电脑只装windows了.免得我老纠结!于是linux便选择了ubuntu. 由于浏览器一直用的是 ...

  7. ubuntu14.04 64位 安装eclipse

    ubuntu14.04 64位 安装eclipse 1 在官网上下载eclipse http://www.eclipse.org/downloads/下载eclipse-jee-luna-SR1-li ...

  8. Windows 7 64位安装cURL

    安装cURL. 1, 下载64位的SSL版cURL,网址: http://curl.download.nextag.com/download/curl-7.21.7-win64-ssl-sspi.zi ...

  9. ubuntu 14.04 64位安装iNodeClient

    ubuntu 14.04 64位安装iNodeClieng(华三校园客服端) http://pan.baidu.com/s/12dpxk ubuntu 14.04 64bit Install H3C ...

随机推荐

  1. .NET Core / C# 开发 IOT 嵌入式设备的个人见解

    https://www.cnblogs.com/whuanle/p/10589496.html

  2. idea启动springboot项目 报错:java.lang.NoSuchMethodError: javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader;

    有一次启动springboot项目的时候,报了一个非常奇怪的错误,说是找不到servletContext,springboot不是自带tomcat的吗? 在网上找了好久,说是用以下方式解决. 解决方式 ...

  3. 记一下JavaScript的几种排序算法

    零.写在最前 排序的方法有很多种,这篇文章只是记录我熟悉的算法: 我发现了一个关于排序算法很有趣的网站,把相关的算法演示做成了动画,有兴趣的同学可以看看! 附上SortAnimate网站链接:http ...

  4. zzw原_环境变量导致date命令显示处理一例

    1.显示时间看不懂 [root@localhost ~]# date201790:02:06 CST 2.注释掉环境变量bash_profile的两行配置 [root@localhost ~]# vi ...

  5. vue中修改了数据但视图无法更新的情况

    数组数据变动:我们使用某些方法操作数组,变动数据时,有些方法无法被vue监测,有些可以 Vue包装了数个数组操作函数,使用这些方法操作的数组去,其数据变动时会被vue监测: push() pop() ...

  6. java替换字符串中的World为Money

    public class Money{ public static void main(String[] args) { String a = "Hello Java World\n&quo ...

  7. Python *Mix_w3

    1.基本数据类型(int,bool,str) int 整数 str 字符串. 一般不存放大量的数据 bool 布尔值. 用来判断. True, False list 列表.用来存放大量数据, []表示 ...

  8. Beta 冲刺 (6/7)

    Beta 冲刺 (6/7) 队名:第三视角 组长博客链接 本次作业链接 团队部分 团队燃尽图 工作情况汇报 张扬(组长) 过去两天完成了哪些任务 文字/口头描述 组织会议 开发wxpy部分功能 展示G ...

  9. fastTime从后台传过来显示格式的处理

    1.可以在控制台用syso查看 QuestionFeedbackView qfv = on_LineManageService.getBringupHead(projectNo);//qfv是一个内含 ...

  10. converting the moment tensor to strie-dip-rake

    在多断层求解的试验中,用到了六个基本矩张量: 而显然,尚不能从图中直接读出strke,dip,rake的值,但有关资料给出了这六个基本矩张量的momet tensor: 而找到一个网站可以方便地将mo ...