Tag: phantomjs

从jsdom迁移到phantomJS? (基本的DOM创build)

M. Bostock指出nodejs的jsdom对svg的支持不够,而且对我来说不支持getBBox() 。 另外,他build议切换到nodejs的PhantomJS。 我检查出来,但这种方法对我来说是新的。 我的nodejs + jsdom脚本创build了一个虚拟的DOM,我的d3js使用它,如下所示: var jsdom = require('jsdom'); jsdom.env( // creates virtual page "<html><body></body></html>", // create my DOM hook, [ 'http://d3js.org/d3.v3.min.js', // add my online dependencies … '../js/d3.v3.min.js', // … & local ones '../js/jquery-2.1.3.min.js'], function (err, window) { //my normal JS or nodejs code here ! } ); 如何将这个nodejs + jsdom迁移到nodejs […]

遇到types错误与casperjs

当我执行casperjs时,它会抛出一个TypeError: #casperjs test.js child_process.js:936 var r = this._handle.spawn(options); ^ TypeError: Bad argument at ChildProcess.spawn (child_process.js:936:24) at exports.spawn (child_process.js:736:9) at Object.<anonymous> (/usr/local/lib/node_modules/phantomjs/bin/phantomjs:22:10) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3 并没有test.js它抛出同样的错误: # casperjs child_process.js:936 var r = this._handle.spawn(options); ^ TypeError: Bad argument at ChildProcess.spawn […]

如何在AWS Lambda上部署phantomjs节点应用程序?

我把一个小的Lambda函数放在一起,使用SpookyJS,CasperJS和PhantomJS工具链来抓取一个网站来进行无头浏览。 这个任务很简单,几个月前在Lambda工作。 我最近不得不改变一些东西,想再次在这个项目上工作,但是开始新鲜起来,很难让Lambda在没有任何错误的情况下运行。 我的问题是如何在Lambda中运行phantomjs ? 我正在运行的示例代码是: spooky.start('http://en.wikipedia.org/wiki/Spooky_the_Tuff_Little_Ghost'); spooky.then(function () { this.emit('hello', 'Hello, from ' + this.evaluate(function () { return document.title; })); }); spooky.run(); 我在Lambda中遇到的错误是: { [Error: Child terminated with non-zero exit code 1] details: { code: 1, signal: null } } 我遵循了各种程序,以确保一切都能在Lambda上运行。 以下是我尝试诊断的一长串列表: 使用node index.js在本地运行并确认它正在工作 将package.json和jsfile upload到Amazon Linux EC2实例以进行编译,build议用于npm安装调用,并在此处介绍 在ec2实例上运行npm install ,并再次运行node index.js以确保输出正确 压缩一切,并使用cli部署到AWS 我的package.json是: […]

摩卡是如何做没有幻影的DOMtesting

我似乎可以用Mocha做DOMtesting。 我以为我需要像PhantomJS这样的无头浏览器。 然后用Mocha来使用PhantomJS有什么好处? (我在使用Yeoman。)

在meteorEPIPE错误的html-pdf

我有一个使用html-pdf呈现PDF服务器端的Meteor应用程序。 该应用程序与mup部署。 本地,一切工作正常。 部署后,我在服务器日志中看到这个错误: events.js:72 throw er; // Unhandled 'error' event ^ Error: write EPIPE at errnoException (net.js:905:11) at Object.afterWrite (net.js:721:19) error: Forever detected script exited with code: 8 error: Script restart attempt #1 版本的东西: Ubuntu 14.04.2 LTS meteor1.0.4.2 Node.js 0.10.37 mup 0.9.7

使用Node.js在服务器上进行HTML渲染

假设我有一个网页,其中只包含一个javascript引用。 当一个浏览器加载页面时,它运行的是实际呈现的javascript。 javascript很大,很复杂,并且会进行大量的XHR调用。 现在我需要使这个页面可search ,即呈现在服务器上的页面。 我试图加载页面phantomJS但它是缓慢的,有时并没有完成整个页面。 所以我想知道是否有其他select。 理想情况下,我需要一个node.js脚本 通过URL加载网页 运行的JavaScript页面,然后 将由javascript创build的DOM序列化为HTML。 PS我可以假设JavaScript是基于React.js

为什么Phantom.js没有评估我的Backbone应用程序的工作?

page.open(My_url, function(status) { page.evaluate(function() { var html = document.documentElement.outerHTML; return html; }, function(result){ res.send(result); }); }); 我有一个骨干应用程序。 “My_url”指向该骨干网页。 当我运行这个代码时,outerHTML不包括渲染的视图。 它只是基本的CSS /脚本/容器持有人。 这就像骨干的应用程序根本没有运行。 如何使评估()返回完全呈现的骨干应用程序(所有的Ajax调用和东西)? 毕竟,这就是Phantom.js的要点

用CasperJS不能要求下划线

我使用CasperJS来运行自动化的前端testing,但在我的testing中遇到了使用其他npm模块的问题。 我知道patchRequire但我相信只能在testing环境之外被调用,因为testing运行器补丁需要自动执行。 我包括它,但结果是一样的。 它说它无法find模块。 我已经确认下划线模块安装在项目根文件夹中的node_modules中。 码 'use strict' _ = require 'underscore' testConfig = testPageUrl: '' testSearchTerm: 'the' config = _.extend testConfig, require 'common/config' 代码在Javascript中 'use strict'; _ = require('underscore'); testConfig = { testPageUrl: '', testSearchTerm: 'the' }; config = _.extend(testConfig, require('common/config')); 错误 CasperError:找不到模块下划线

噶:找不到variables:出口

我写了一个节点模块,可以用于后端和客户端 (exports || window).Bar= (function () { return function () { …. } })(); 现在我的业力testing使用PhantomJs并抱怨不存在的exportsvariables gulp.task('test', function () { var karma = require('karma').server; karma.start({ autoWatch: false, browsers: [ 'PhantomJS' ], coverageReporter: { type: 'lcovonly' }, frameworks: [ 'jasmine' ], files: [ 'bar.js', 'tests/bar.spec.js' ], junitReporter: { outputFile: 'target/junit.xml' }, preprocessors: { 'app/js/!(lib)/**/*.js': 'coverage' }, reporters: […]

如何使用node.JS中的phantomJs将html内容呈现为pdf文件

我怎样才能生成一些PDF文件的HTML内容,并使用node.js中的phantom.js呈现文件和内容浏览器?