chromeDriver下载地址:http://chromedriver.storage.googleapis.com/index.html

谷歌浏览器Chrome和驱动程序的对照表https://blog.csdn.net/allthewayforward/article/details/81736418

selenium已经放弃PhantomJS,了,建议使用火狐或者谷歌无界面浏览器。

解决方案
selenium版本降级
通过pip show selenium显示,默认安装版本为3.8.1。
将其卸载pip uninstall selenium,重新安装并指定版本号pip install selenium==2.48.0。
再次运行,发现没有报错,搞定!

使用无界面浏览器
Selenium+Headless Firefox
Selenium+Headless Firefox和Selenium+Firefox,区别就是实例option的时候设置-headless参数。

前提条件:
- 本地安装Firefox浏览器
- 本地需要geckodriver驱动器文件,如果不配置环境变量的话,需要手动指定executable_path参数。

from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options

def main():
options = Options()
options.add_argument('-headless')
driver = Firefox(executable_path='./geckodriver', firefox_options=options)
driver.get("https://www.qiushibaike.com/8hr/page/1/")
print(driver.page_source)
driver.close()

if __name__ == '__main__':
main()

Selenium+Headless Chrome
与Firefox类似,双手奉上。

前提条件:
- 本地安装Chrome浏览器
- 本地需要chromedriver驱动器文件,如果不配置环境变量的话,需要手动指定executable_path参数。

示例:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

def main():
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome(executable_path='./chromedriver', chrome_options=chrome_options)
driver.get("https://www.baidu.com")
print(driver.page_source)
driver.close()

if __name__ == '__main__':
main()

selenium无界面chromedriver的更多相关文章

  1. selenium无界面执行和反爬

    selenium无界面执行和反爬 无界面执行 from selenium import webdriver from selenium.webdriver.chrome.options import ...

  2. selenium 无界面跑UI脚本

    from selenium.webdriver.chrome.options import Options from selenium import webdriver import time chr ...

  3. linux无界面模式安装selenium+chrome+chromedriver并成功完成脚本(亲测可用)

    环境:docker centos 7.4 能通外网 写好的selenium脚本. 具体步骤: 一:安装selenium  这是最简单的 直接利用 pip3 install selenium 二 安装c ...

  4. python selenium chrome有界面与无界面模式

    from selenium.webdriver.chrome.options import Options from selenium import webdriver # 无界面模式 def Chr ...

  5. XVFB实现selenium在linux上无界面运行安装篇

    selenium在linux上无界面运行,其实是非常简单的.具体的方法有使用HtmlUnitDriver或者PhantomJSDriver,有时间我会写写关于这两个东东的文章,其实基本和ChromeD ...

  6. centos 无界面 服务器 安装chrome部署chromedriver

    转:https://blog.csdn.net/u013849486/article/details/79466359 基本 做完了,要弄进docker里面去了的时候,才搜到 docker-chrom ...

  7. selenium+python自动化100-centos上搭建selenium启动chrome浏览器headless无界面模式

    环境准备 前言 selenium在windows机器上运行,每次会启动界面,运行很不稳定.于是想到用chrome来了的headless无界面模式,确实方便了不少. 为了提高自动化运行的效率和稳定性,于 ...

  8. ubuntu中如何安装selenium+chrome(headless)无界面浏览器?

    selenium是一个Web的自动化测试工具,它可以根据我们的指令,让浏览器自动加载页面,获取需要的数据,甚至页面截屏,或者判断网站上某些动作是否发生.但是它自身不带浏览器,不支持浏览器的功能,因此它 ...

  9. selenium(六)Headless Chrome/Firefox--PhantomJS停止支持后,使用无界面模式。

    简介: 以前都用PhantomJS来进行无界面模式的自动化测试,或者爬取某些动态页面. 但是最近selenium更新以后,'Selenium support for PhantomJS has bee ...

随机推荐

  1. mp4格式(转帖加修改) 转载

    下面的软件下载地址:http://download.csdn.net/source/2607382 ftyp: 这是一个筐,可以装mdat等其他Box. 例:00 00 00 14 66 74 79 ...

  2. 吴裕雄 python 机器学习-Logistic(1)

    import numpy as np def loadDataSet(): dataMat = [] labelMat = [] fr = open('D:\\LearningResource\\ma ...

  3. 历届试题 对局匹配-(dp)

    问题描述 小明喜欢在一个围棋网站上找别人在线对弈.这个网站上所有注册用户都有一个积分,代表他的围棋水平. 小明发现网站的自动对局系统在匹配对手时,只会将积分差恰好是K的两名用户匹配在一起.如果两人分差 ...

  4. java 集成友盟推送

    原文:https://blog.csdn.net/Athena072213/article/details/83414743 最近应公司业务需求需要完善友盟推送,认真看了官方文档后其实很简单,只需要细 ...

  5. 函数putText()在图片上写文字

    #include <iostream> #include <opencv2/opencv.hpp> using namespace std; using namespace c ...

  6. SAP FI模块常用事务代码

    F.52 G/L: Acct Bal.Interest Calculation 总帐:计算科目余额利息 F-06       Post Incoming Payments 收款记帐 F-07      ...

  7. Linux下怎么创建和进入带有空格的文件夹

    有时候需要创建带有空格的文件夹,虽然这不是一个好的习惯,但是偶尔会遇到.用的最多的是很多时候需要进入带有空格的文件夹,如"a b"是一个文件夹名. 创建:mkdir "a ...

  8. 同时启动多个Tomcat 和 Linux部署多个tomcat

    a.减压2份tomcat文件 b.修改其中一个tomcat 的http访问端口(默认为8080端口,这里改为8091) c.修改其中一个tomcat 的Shutdown端口(默认为8005端口,这里改 ...

  9. cakephp 如何在一个模型里调用另一个模型

    $admin_users = ClassRegistry::init('AdminUsers'); $admin_name = $admin_users->find('list',array( ...

  10. Multiple APK Support

    [Multiple APK Support] Multiple APK support is a feature on Google Play that allows you to publish d ...