- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我想在我的 Raspberry Pi 上使用 Selenium WebDriver
和 PhantomJS
作为 headless 浏览器运行 Python 脚本 运行 Raspbian。
我最初是在 OS X 中编写脚本的,它运行良好。但是在尝试让它在 Raspberry 上运行时,我遇到了问题。
尝试运行脚本时,出现此错误:
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /usr/bin/phantomjs
脚本的简要版本:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
user_agent = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) " +
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36")
dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.userAgent"] = user_agent
serv_args = ["--ignore-ssl-errors=false", "--ssl-protocol=tlsv1",
"--disk-cache=false"]
driver = webdriver.PhantomJS(executable_path="/usr/bin/phantomjs",
desired_capabilities = dcap, service_arguments = serv_args, port=65000)
我看到其他人遇到与我类似的问题——有不同的解决方案——大多数似乎涉及自己构建 PhantomJS,或者克隆并安装一个适用于 Raspberry 的 Github 分支(现在与主要的 PhantomJS 项目不同步) .
/usr/local/bin
等位置,我该怎么做? PhantomJS webpage 上可用的二进制文件适用于 linux-x86
和 linux-i686
,所以我假设它们不能在 Raspberry Pi 2 B ARM Cortex A-7 处理器上工作.Python 2.7.9
virtualenv
并在其中安装了所有 Python 模块;例如pip install selenium
,并尝试在此处运行脚本sudo apt-get install phantomjs
安装了最新版本的 PhantomJSufw
防火墙最佳答案
好的,我将从解决方案开始,这里有一个为 arm 编译的版本 phantomjs-linux-armv6l , 在 pi 上运行以下命令:
$ cd /tmp
$ wget https://github.com/aeberhardo/phantomjs-linux-armv6l/archive/master.zip
$ unzip master.zip
$ cd phantomjs-linux-armv6l-master
$ bunzip2 *.bz2 && tar xf *.tar
我补充说:
sudo cp phantomjs-1.9.0-linux-armv6l/bin/phantomjs /usr/bin
因此 phantomjs 将在您的道路上。
pi@raspberrypi ~ $ phantomjs --version
1.9.0
pi@raspberrypi ~ $ phantomjs
phantomjs>
现在我们已经完成了,是时候测试了:
pi@raspberrypi ~ $ cat test.py
#!/usr/bin/python
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get('http://stackoverflow.com/questions/36314771/how-to-install-phantomjs-for-use-with-python-selenium-on-the-raspberry-pi/36388824#36388824')
a = driver.find_element_by_xpath('//*[@id="question-header"]/h1/a')
print(a.text)
print(driver)
pi@raspberrypi ~ $ python test.py
How to install PhantomJS for use with Python Selenium on the Raspberry Pi?
<selenium.webdriver.phantomjs.webdriver.WebDriver (session="b184e110-f9c4-11e5-aede-7f5c42f062d7")>
来自faq . 从 PhantomJS 1.5 开始,它是纯 headless 的,不再需要运行 X11/Xvfb。。
我尝试使用 xvfb-run 并导出显示,使用 init.d 中的 shell 脚本启动 xvfb,我进一步能够从 bash headless 运行 iceweasel 没问题,但仍然当谈到 phantomjs 和 Selenium 时,不要抽雪茄。我认为这可能只是因为 selenium 和 phantomjs 版本之间的不兼容,不管有 1.9.0 还是真正的 headless 浏览更可取。
当我找到上面的链接时,我正在设置工具链并打算自己编译,对于任何对交叉编译感兴趣的人,crosstools-ng让生活变得更轻松。
我运行的是 arm6,还有一个 compiled version对于使用 2.0.0 的 arm7,依赖项是:
sudo apt-get install flex bison gperf ruby perl libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev libpng-dev libjpeg-dev python libX11-dev libxext-dev
安装过程,我已经将二进制文件解压缩到 dropbox:
wget https://www.dropbox.com/s/epj1rji9d239dco/phantomjs
chmod +x phantomjs
sudo cp phantomjs /usr/bin
原来的github链接是phantomjs-2.0.0-armv7
关于python - 如何在 Raspberry Pi 上安装 PhantomJS 以与 Python Selenium 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36314771/
我有一个运行 Raspbian 的 Raspberry Pi 1。我尝试在 Raspberry Pi 3 上运行 SD 卡,但它没有启动。 我已经阅读了有关升级 Raspberry Pi 2 安装以在
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我目前正在尝试RadiusNetworks发布的Raspberry Pi iBeacon教程,网址为 http://developer.radiusnetworks.com/2013/10/09/ho
我的公司使用 Raspberry Pi 3 作为产品中的嵌入式 Controller 。用户不会优雅地关闭它,他们只是扳动一个开关。为避免损坏,/boot 和/root 文件系统是只读的。这似乎是防弹
如何使用 Raspberry Pi 作为 b/w USB Tethered 手机和路由器的桥接器,使用“以太网电缆 b/w Raspberry Pi 和路由器”和“USB 电缆 b/w 手机和 Ras
我关注了一个名为Creating an Electron Application for the Raspberry Pi的博客,内容涉及使用Buster OS在Raspberry Pi中启动Elec
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
我有一个树莓派,并且已经从 raspbmc.com 加载了最新的独立版本。在使用 XBMC 时,我看到 CPU 使用率始终在 90% 以上。查看 XBMC wiki 和常见问题解答后,脏区域似乎是减少
我现在正在做一个小项目。我希望 python 脚本在登录到 GUI 后自动运行。 我按照这里的步骤操作:https://www.raspberrypi.org/forums/view ... 91&t
我正在使用 Android Things 在 Raspberry Pi 上构建应用程序并且我有 7 inch touch screen ,但屏幕永远不会关闭。 是否可以像 Android 手机一样设置
我正在执行一组事件以确保 Redis 在一组嵌入式系统(包括 Raspberry PI)中运行良好。为了修复执行未对齐内存访问的 Redis 的某些代码路径(由于 Redis 3.2 中引入的更改),
我正在尝试使用 Tanuki Java Service Wrapper。 我使用的硬件是带有 Raspbian wheezy 发行版的 Raspberry Pi。 (见 http://www.rasp
我希望构建一个以全屏模式在 Raspberry Pi 上运行的应用程序。我已经尝试过 JavaFX 和基于 Swing 的应用程序,但性能非常糟糕。 在我开始使用 SDL( http://www.li
我的项目在/home/pi/app中 以npm start开头 启动操作系统后如何启动应用程序? ****西类牙文 Mi proyecto esta zh/home/pi/app Arranca la
我正在尝试安装 Kappelt gBridge在 Raspberry Pi 3 B 型上,使用本指南:https://doc.gbridge.io/selfHosted/hostItYourself.
我正在使用我的 Pi 作为文件服务器,最近当我登录时,我看到一条错误消息,指出 libarmmem.so(无法打开共享对象文件),尽管有一些建议运行 apt-get update + 升级它并没有带来
我正在尝试使用 Raspberry# 库通过 Raspberry PI 上的 GPIO 引脚(打开和关闭)执行基本任务。根据 github 上的示例:https://github.com/raspbe
如标题所述,我在将一些用户空间中断代码从另一个 armv7 嵌入式 linux 平台移植到 Raspberry Pi 2 Model B 时遇到问题。 我知道 wiringPi 库(并让它以这种方式工
我正在尝试为 Raspberry Pi B+ 交叉编译 Tensorflow-Lite。为此,我正在关注 these instructions来自官方网站,它们是: git clone https:/
我正在尝试使用 PulseAudio RTP 将音频从 Linux Mint 桌面流式传输到运行 LibreELEC (Kodi) 的 RaspberryPi 3B。我可以使用 RTP 多播成功地流式
我是一名优秀的程序员,十分优秀!