栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在Raspberry Pi上安装PhantomJS与Python Selenium一起使用?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Raspberry Pi上安装PhantomJS与Python Selenium一起使用?

好的,我将从解决方案开始,这里是phantomjs-linux-
armv6l
为arm编译的版本,在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 --version1.9.0pi@raspberrypi ~ $ phantomjsphantomjs>

现在我们已经完成了,该测试一下了:

pi@raspberrypi ~ $ cat test.py#!/usr/bin/pythonfrom selenium import webdriverdriver = 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")>

从常见问题解答。 从PhantomJS 1.5开始,它是无头的,并且不再需要运行X11
/ Xvfb。

我尝试使用 xvfb运行
并导出显示,并使用init.d中的shell脚本启动xvfb,我可以使用bash来运行iceweasel毫无问题,但在phantomjs和硒方面仍然没有雪茄。我认为这可能归因于硒和phantomjs版本之间的不兼容,而不管拥有1.9.0和真正的无头浏览是更可取的。

当我找到上面的链接时,我正处于建立工具链的过程中,并且打算尝试自己编译自己。对于任何对交叉编译感兴趣的人,crosstools-
ng使工作变得更加轻松。

我正在运行arm6,还有使用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

安装过程中,我已将二进制文件提取到保管箱:

wget https://www.dropbox.com/s/epj1rji9d239dco/phantomjschmod +x phantomjssudo cp phantomjs /usr/bin

原始的github链接是phantomjs-2.0.0-armv7



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/388264.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号