Ubuntu 无界面使用selenium chrome + headless

1. 安装 selenium :

sudo pip install selenium

2. 安装 chromdriver: 进入 淘宝镜像源 下载 chromdriver, 可以查看 notes.txt 文件,看chrome 和ChromDriver 两者相对应的兼容版本

下载地址:https://npm.taobao.org/mirrors/chromedriver

3. 下载chrome : 下载 chromedriver_linux64.zip

下载地址:https://www.slimjet.com/chrome/google-chrome-old-version.php

4. 将 chromdriver 文件放到线上服务器 /usr/bin/ 下(首先先解压压缩包) ,将google-chrome-stable_current_amd64.deb上传线上服务器(通过下面的命令进行解压)

5. 安装chrome,执行如下命令:

sudo dpkg -i google-chrome*.deb   sudo apt-get install -fgoogle-chrome --version      # 查看版本

6. 编写测试脚本

from selenium import webdriverchrome_options = webdriver.ChromeOptions()chrome_options.add_argument('--headless')chrome_options.add_argument('--disable-gpu')chrome_options.add_argument('--no-sandbox') # 这个配置很重要client = webdriver.Chrome(chrome_options=chrome_options, executable_path='/usr/bin/chromedriver')    # 如果没有把chromedriver加入到PATH中,就需要指明路径client.get("https://www.baidu.com")print (client.page_source.encode('utf-8'))client.quit()

Ubuntu 无界面使用selenium chrome + headless相关推荐

  1. 爬虫Spider 08 - chromedriver设置无界面模式 | selenium - 键盘操作 | 鼠标操作 | 切换页面 | iframe子框架 | scrapy框架

    文章目录 Spider 07回顾 cookie模拟登陆 三个池子 selenium+phantomjs/chrome/firefox Spider 08 笔记 chromedriver设置无界面模式 ...

  2. 【一文搞懂】linux无界面模式安装chrome和chromedriver

    1. 安装chrome 查看liunx上所有关于chrome已安装的软件信息 yum list | grep chrome chrome官网下载linux 对应包(rpm:centos) yum in ...

  3. selenium +chrome headless Manual 模式渲染网页

    可以看看这个里面的介绍,写得很好.https://duo.com/blog/driving-headless-chrome-with-python from selenium import webdr ...

  4. selenium +chrome headless Adhoc模式渲染网页

    mannual和adhoc模式比较 Manual vs. Adhoc In the script above, we start the ChromeDriver server process whe ...

  5. CentOS7下无界面使用Selenium+chromedriver进行自动化测试

    安装python与pip python及pip安装请移步:<Linux下使用源码包安装Python> 安装selenium 你可以使用 pip 命令来安装 Selenium: pip in ...

  6. (转载)Selenium + Chrome headless 报ERROR:gpu_process_transport_factory.cc(1007)]

    2019独角兽企业重金招聘Python工程师标准>>> Selenium不再推荐使用PhantomJS,会报如下警告 UserWarning: Selenium support fo ...

  7. selenium操作无界面chrome浏览器

    今天展示一下python操作无界面的chrome浏览器.主要利用selenium 和对应自己电脑上Chrome浏览器版本的webdriver.chrome版本的webdriver下载地址:http:/ ...

  8. selenium(Chrome)测试 ---“无界面”+“免登陆”+“禁图片加载”+“取消浏览器受软件测试提示”

    from selenium import webdriveroption = webdriver.ChromeOptions()# 1.无头/无界面浏览器 option.add_argument(&q ...

  9. 【避坑 超详细】Ubuntu使用python的selenium以及chrome模拟真实浏览器访问网页

    在Ubuntu系统上使用python的selenium,另外加上chrome和chromedriver,用于模拟浏览器访问网页. 下面教程在阿里云的Ubuntu 14.04 64位测试成功,其他lin ...

最新文章

  1. WebView显示的网页在大分辨率屏下被放大--解决方案
  2. UA SIE545 优化理论基础2 凸函数 概念 理论 总结
  3. eclipse工作空间在哪里配置?
  4. 使用websockets,后台实时发数据,前台实时接受数据,并集成到Django
  5. php生成文件index.html,Typecho生成静态首页index.html文件
  6. Fisher–Yates shuffle 算法
  7. UILabel---.tff格式字体
  8. C语言——变量篇(一)变量关键字static、auto、extern、register
  9. 拓端tecdat|R语言使用 LOWESS技术图分析逻辑回归中的函数形式
  10. 换协议、改代码,Elastic要逼开发者二选一?
  11. 浏览器实现word在线预览
  12. 数据库锁 与 事务隔离级别
  13. DRM 驱动程序开发(VKMS)
  14. cad 打开硬件加速卡_CAD2020 使用图块插入命令特别卡怎么办?
  15. Win2003可用序列号(标准版与企业版)
  16. opencv3中的图像混合操作
  17. Chrome浏览器未连接到互联网的解决办法
  18. 京东全民营业拿金币之辅助脚本网页版
  19. springboot同时接受文件和多个参数
  20. 派大星python代码_一些简单的python例子

热门文章

  1. 达沃斯议程对话会:张亚勤解读人工智能发展 3R 原则
  2. 4场直播,哈工大、亚马逊等大咖为你带来机器学习与知识图谱的内容盛宴
  3. 一文告诉你,如何使用Python构建一个“谷歌搜索”系统 | 内附代码
  4. 万字干货 | Python后台开发的高并发场景优化解决方案
  5. 面向可解释的NLP:北大、哈工大等提出文本分类的生成性解释框架
  6. 深度研究自然梯度优化,从入门到放弃 | Deep Reading
  7. 清华首批7门标杆课程,到底有多牛?
  8. 理解 Linux 的虚拟内存
  9. Spring Boot 解决跨域问题的 3 种方案!
  10. HTTP/2做错了什么?刚刚辉煌2年就要被弃用了!?