Running Chromedriver on Ubuntu Server headlessly(在 Ubuntu Server 上无头运行 Chromedriver)
问题描述
我在 Java (1.8) 中使用 Selenium 和 Chromedriver 来做一些自动网络爬取:
I am using Selenium with Chromedriver in Java (1.8) to do some automated web crawling:
我正在尝试迁移到 Ubuntu 16.04 服务器.在服务器上,我安装了 Ubuntu chromedriver 2.37 版、chrome 65 版.根据 chromedriver 文档,这些版本是兼容的.我已经更改了指定 Ubuntu 中 chromedriver 位置的代码:
I am attempting to migrate to an Ubuntu 16.04 Server. On the server I have installed the Ubuntu chromedriver version 2.37, chrome version 65. According to the chromedriver documentation these versions are compatible. I have changed the code specifying the location of the chromedriver in Ubuntu:
在运行我的程序之前,我启动了 xvfb:
Prior to running my program I start up xvfb:
然后执行我的程序:
以下内容打印到控制台:
The following is printed to the console:
推荐答案
这个错误确实让我们知道发生了什么错误:
The error does gives us some idea about whats wrong happening :
当您尝试在 Ubuntu Server headless 上启动 Chromedriver 和 Chrome 时,您必须通过几个选项如下:
As you are trying to initiate Chromedriver and Chrome on Ubuntu Server headless you have to pass a couple of Options as follows :
附加说明
根据强制性要求和#1341 确保以下内容:
- Chromedriver 在
/usr/local/bin/
内 - Chrome 浏览器 在
/usr/bin/google-chrome
中
- Chromedriver is within
/usr/local/bin/
- Chrome Browser is within
/usr/bin/google-chrome
沙盒的故事
这篇关于在 Ubuntu Server 上无头运行 Chromedriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!