1. 安装 selenium : sudo pip install selenium

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

3. 下载chrome : 下载 chromedriver_linux64.zip

4. 将 chromdriver 文件放到线上服务器 /usr/bin/ 下 ,将google-chrome-stable_current_amd64.deb上传线上服务器

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

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

6. 编写测试脚本

from selenium import webdriver

chrome_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='/home/chromedriver') # 如果没有把chromedriver加入到PATH中,就需要指明路径 client.get("https://www.baidu.com")
print (client.page_source.encode('utf-8')) client.quit()

  

Ubuntu 无界面使用selenium chrome + headless的更多相关文章

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

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

  2. centos 无界面安装selenium+chrome+chromedirver的设置

    配了一中午的,好不容易正好记录下. 1.我的centos的位数 输入rpm -q centos-release 结果:centos-release-7-4.1708.el7.centos.x86_64 ...

  3. ubuntu服务器端使用无界面selenium+ chrome + headless

    本来想直接用Ubuntu系统里面的firefox来实现selenium自动操作签到的,但是总是出各种问题.没办法,改为Chrome.参考:Ubuntu 线上无界面服务器 使用selenium chro ...

  4. 笔记-selenium+chrome headless

    笔记-selenium+chrome headless 1.      selenium+chrome headless phantomjs与selenium分手了,建议使用其它无头浏览器. chro ...

  5. selenium chrome headless无界面引擎

    注意:PhantomJS已被舍弃 chrome headless 在打开浏览器之前添加参数 import time import sys from selenium import webdriver ...

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

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

  7. chrome浏览器爬虫WebDriverException解决采用python + selenium + chrome + headless模式

    WebDriverException: Message: unknown error: Chrome failed to start: crashed 第一种:如果出现下面情况: chrome浏览器有 ...

  8. Selenium + Chrome headless 报ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context 可忽略并配置不输出日志

    Selenium不再推荐使用PhantomJS,会报如下警告 UserWarning: Selenium support for PhantomJS has been deprecated, plea ...

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

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

随机推荐

  1. 壁虎书1 The Machine Learning Landscape

    属性与特征: attribute: e.g., 'Mileage' feature: an attribute plus its value, e.g., 'Mileage = 15000' Note ...

  2. Web API Request Content多次读取

    使用自宿主OWIN 项目中要做日志过滤器 新建类ApiLogAttribute 继承ActionFilterAttribute ApiLogAttribute :  ActionFilterAttri ...

  3. 单机单网卡最大 tcp 长连接数是 65535 吗

    在Linux里,如果是作为客户端或者负载均衡器的节点连接多个服务器,在connect()服务器之前, 调用bind()先绑定IP地址(通常是在多网卡的场景),即使使用bind(IP, port=0), ...

  4. 关于SQL配置管理工具无法打开0x8004100e问题!

    今天犯了个很“2”得问题,因为在远程数据库可以访问,并且也在安装程序中有看到装有SQLserver Mamngement Studio及其它程序,所以想在本地使用数据库应该可以但没想却总是报SQL配置 ...

  5. 11、jeecg 笔记之 界面常用整理 - 方便复制粘贴

    1.datagrid 操作按钮(按钮样式) 操作按钮的显示主要依赖于 <t:dgCol title="操作" field="opt"  ></ ...

  6. [zw]薰衣草/紫花苜蓿+桑椹/(黑红蓝)霉等植物

    有趣的问题 为什么越长大觉得时间过得越快? 另参考,讨论的比较深刻 为何人随着年龄的增大觉得时间过得越来越快? 小时候,你会花上十分钟去观察一只蚂蚁的活动. 小时候,走路上碰到一只鸟儿你都会新奇不已. ...

  7. mac 添加环境变量(jmeter添加至环境变量中)

    Mac系统的环境变量,加载顺序为:a. /etc/profileb. /etc/pathsc. ~/.bash_profiled. ~/.bash_logine. ~/.profilef. ~/.ba ...

  8. ELK日志分析解决方案

    概要 ELK(Elasticsearch , Logstash, Kibana的简称)是目前比较流行的日志分析解决方案,核心包括了三个部分 Elasticsearch:日志查询分析引擎 Logstas ...

  9. 关于cc.easesinexxx 与 cc.easeexponentiallxxx 的几种效果简单描述

    代码样例: var biggerEase = cc.scaleBy(0.7,1.2,1.2).easing(cc.easeSineInOut()) 呈正弦变化 1)CCEaseSineIn       ...

  10. Python3.0科学计算学习之绘图(四)

    绘制三维图: mplot3d工具包提供了点.线.等值线.曲面和所有其他基本组件以及三维旋转缩放的三维绘图. 1.散点的三维数据图 from mpl_toolkits.mplot3d import ax ...