Tag: phantomjs

如何用nightmarejs正确地停止phantomjs实例

我想用恶梦获取我的networking应用程序的屏幕截图。 运行代码时没有错误,退出是干净的,没有pha​​ntomjs实例被留下。 var Nightmare = require('nightmare'); var Screenshot = require('nightmare-screenshot'); var nightmare = new Nightmare(); var url = process.argv[2]; var url = process.argv[3]; nightmare .goto(url) .wait('#selector') .use(Screenshot.screenshotSelector(path, '#selector')) .run(function (err, nightmare) { if (err) console.log('Error'); else console.log('Done.'); nightmare.teardownInstance(); nightmare.end(); }); 但是,当有一些错误,如networking没有运行,select器不存在。 幻影的实例仍然未被使用。 $ ps -ax | grep phantom 6065 ttys004 0:00.00 grep phantom 6050 ttys005 […]

检测操作系统版本并使用正确的PhantomJS二进制文件

我目前正在使用OS X在Node.js&Nwjs内部使用PhantomJS。但是,我想知道如果我将应用程序部署到Windows用户,他们是否也能够运行该应用程序? 有没有办法来检测用户的操作系统,并使用正确的二进制文件?

了解Spooky JS中的范围

这个SpookyJS的实现真的很鬼。 在使用Gulp运行Mocha + SpookyJStesting时,我无法看到大部分控制台日志输出。 我一直在关注SpookyJS的github 页面上的快速入门步骤。 为什么我看不到这些控制台日志输出? describe('test', function () { it('test 1', function(done){ try { var Spooky = require('spooky'); } catch (e) { var Spooky = require('../lib/spooky'); } var spooky = new Spooky({ child: { transport: 'http' }, casper: { logLevel: 'debug', verbose: true } }, function (err) { if (err) { e = […]

问题在Ubuntu下安装业务,茉莉花和phantomjs与NPM

我正在尝试使用yeomen创buildangular度项目。我在yeomen站点中安装了grunt-cli,bower,angular-generator。但是grunt的构build不成功,抛出了以下未满足的依赖性错误。 npm WARN EPEERINVALID grunt-karma@0.12.1 requires a peer of karma@^0.13.0 || >= 0.14.0-rc.0 but none was installed. npm WARN EPEERINVALID karma-jasmine@0.3.6 requires a peer of jasmine-core@* but none was installed. npm WARN EPEERINVALID karma-phantomjs-launcher@0.2.2 requires a peer of karma@>=0.9 but none was installed. npm WARN EPEERINVALID karma-phantomjs-launcher@0.2.2 requires a peer of phantomjs@>=1.9 but none was […]

从PhantomJS站点上的Ajax请求获取状态代码

我们正在使用PhantomJS访问我们公司的内部网站并截图。 这个脚本基本上是PhantomJS的官方例子之一,增加了一个waitTimevariables( https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js ) var page = require('webpage').create(), system = require('system'), address, output, size; //waitTime is how long to to wait for kibana and the data to load in millis. //Increase this if your queries appear incomplete in your PDFs. 10s seems to work for me. var waitTime = 10 * 1000; if (system.args.length < […]

页面error handling(PhantomJS)

我试图找出如何处理简单的Pageres脚本中的错误。 目前,它运行时,它运行的只是我想要的。 但是当出现错误时,它会挂起,服务器需要重新启动。 我想要的是: 如果出现错误,请将消息写入日志文件(在/ var / log中) 出口 有任何想法吗? 我尝试了各种各样的东西,我不认为这是很难,但我根本没有经验的Node或PhantomJS。 const Pageres = require('pageres'); const pageres = new Pageres({ delay: 2, filename: '<%= url %>-<%= size %><%= crop %>' }) .src('https://example.com/', ['1920×1080'], {crop: false}) .dest('/home/storepictures/') .run() .then(() => console.log('done'));

运行cucumberjs ft。selenium,phantomjs,webdriverio时出错

我已经在全球安装了phantomjs npm install -g phantomjs 用java -jar selenium-standalone-2.52.0.jar启动selenium 像这样正确configurationcucumber的World对象: var options = { //desiredCapabilities: { browserName: 'internet explorer' }, // WORK //desiredCapabilities: { browserName: 'chrome' }, // WORK desiredCapabilities: { browserName: 'phantomjs' }, // NOT WORK waitforTimeout : 2000, host: '127.0.0.1', port: 4444 }; this.browser = webdriverio.remote(options); 它与Chrome&IE一起工作,但幻灯片失败。 这是我从Selenium控制台得到的错误: 错误 – org.apache.commons.exec.ExecuteException:执行失败(退出值:-559038737。由java.io.IOException引起:无法运行程序“C:\ Program Files(x86)\ nodejs […]

使用phantom.js和node.js安排PDF生成

我是node.js和phantom.js的新手,所以我不知道如何更好地利用它们。 我有100多所学校的价目表,可以从各自的学校页面下载为PDF格式。 我们所做的是生成PDF并在一夜之间上传到服务器。 现在我们想要使用node.js和phantom.js来批量生成PDF,并尽可能地自动完成这个过程。 以下链接不是价格表网页,而是testingPDF的示例url。 “` var schedule = require('node-schedule'), path = require('path'), childProcess = require('child_process'), phantomjs = require('phantomjs'), binPath = phantomjs.path, childArgs = [ // phantomjs rasterize.js http://codefight.org codefight.pdf path.join(__dirname, 'rasterize.js'), 'http://codefight.org/', 'codefight.pdf', '400*300' ] // add all the URLs and name of PDF here var pdfSources = [ ['codefight.pdf', 'http://codefight.org/'], ['dltr.pdf', 'http://dltr.org/'] ]; […]

在承诺链中等待DOM元素中的突变

我在Node.js中制作了一些网页抓取工具,用PhantomJS拍摄了一个网站上出现的地图。 但是,页面打开后,会在地图所在的位置显示加载消息。 地图准备就绪后,消息消失( visibility: hidden ),并显示地图。 正因为如此,我不能调用page.render()直到hidden #loader (或者我会得到一个加载消息的图片,而不是很酷)。 // … Open the page .then(function(content) { return page.evaluate(function() { // Wait for #loading to get hidden somehow … var clipRect = document.getElementById('map').getBoundingClientRect(); return { top: clipRect.top, left: clipRect.left, width: clipRect.width, height: clipRect.height }; }); }) // Render and process the picture … 我考虑使用突变观察者 ,但无法find使用它的方法,因为我处于承诺链中 ,并且事件侦听器不能按我的要求工作。 […]

等待CasperJS的多个替代select器

我有一个应用程序,可以对我的CasperJS脚本的行动有不同的反应,所以我需要同时等待不同的select器,并根据第一个匹配的select器。 但是,看起来CasperJS一次只能等待一个select器。 我如何等待不同的反应,并将脚本的执行转移到不同的分支?