Tag: phantomjs

phantomjs在访问aws-sdk时找不到节点模块“encryption”

我有一个应用程序正在使用幻影js和nodejs应用程序。 我正在使用节点应用程序中的几个节点模块,这是通过幻像js运行。 我需要使用亚马逊节点aws-sdk。 我安装了它 npm install aws-sdk 该节点的应用程序能够find一旦我这样做 var AWS = require('aws-sdk'); 但它开始提示其他本地节点js模块的错误,其中三个具体是“encryption”,“定时器”,“path”。 我检查了/ usr / lib / nodejs文件夹和那些在那里,所以如何phantomjs节点应用程序无法find它们? 具体的错误 Error: Cannot find module 'crypto' phantomjs://platform/bootstrap.js:299 in require phantomjs://platform/bootstrap.js:263 in require phantomjs://platform/util.js:4 TypeError: undefined is not a function (evaluating 'AWS.util.update') phantomjs://platform/core.js:16 Error: Cannot find module 'path' phantomjs://platform/bootstrap.js:299 in require phantomjs://platform/bootstrap.js:263 in require phantomjs://platform/api_loader.js:3 Error: Cannot […]

带有AWS Lambda的CasperJs

我使用node-casperjs-aws-lambda来创build我的casperjs,我将phantomjs版本更新到2.1.1,并使用Lambda上的基本示例部署代码,这非常完美 但是,当我尝试用亚马逊网站testingcasperJs时,它不起作用。 该页面不加载,但在本地,这是工作: // Simple Javascript example var casper = require('casper').create(); casper.options.verbose = true; casper.options.logLevel ="debug"; casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10; rv:33.0) Gecko/20100101 Firefox/33.0'); var amazonProduct = 'https://www.amazon.fr/gp/product/B017DBB1S8'; console.log('Loading a web page: ' + amazonProduct); // Ouvre la page produit casper.start(amazonProduct, function() { this.echo('Page title is: ' + this.getTitle()); }); casper.run(); 云监视debugging模块给我: Loading […]

AWS Lambda上的PhantomJS总是超时

我尝试在AWS Lambda上创build一个从PhantomJS创buildPDF文件的任务,然后再上传到AWS S3。 现在,我尝试在Lambda上运行它,但总是超时。 我的Lambda有128MB的内存。 运行时是node.js 4.4.3。 这是我从Lambda获得的错误 "errorMessage": "2017-03-01T08:05:56.255Z dfd4cfe8-fe55-11e6-bf24-e7edf412e037 Task timed out after 10.00 seconds" 这些也是日志输出 REPORT RequestId: dfd4cfe8-fe55-11e6-bf24-e7edf412e037 Duration: 10000.08 ms Billed Duration: 10000 ms Memory Size: 128 MB Max Memory Used: 29 MB 2017-03-01T08:05:56.255Z dfd4cfe8-fe55-11e6-bf24-e7edf412e037 Task timed out after 10.00 seconds 这是我的代码。 Index.js var childProcess = require('child_process'); var path = require('path'); […]

PhantomJS更新资源文件path

我有一个nodejs + phantomjs设置。 我正在尝试生成HTML,并将其提供给SEO的机器人。 该应用程序目前的作品,但我想提高性能。 由于大量的js文件被加载,我正在尝试更新phantomjs中的资源path,以便将资源指向本地,而不是在浏览器中发出http请求以提高性能。 我正在做这样的事情。 page.onResourceRequested = function (requestData, request) { if(requestData.url.indexOf('.js') > 0) { requestData.url = requestData.url.replace("http://foo.com/","/path to local directory of the resources"); } 但是这似乎没有工作。 在networking标签中,我仍然可以看到从外部源拉取的资源。 有其他的方法吗? 我也看着幻灯片caching,似乎没有帮助。 非常感谢帮助。 谢谢。

这是慢的,还是PhantomJS? 替代刮刀?

我刚刚写了我的第一个脚本,但我发现它运行非常缓慢。 我对pjscrape和phantomjs都是新手,所以我不知道哪个是罪魁祸首。 我正在从本地主机加载文件,所以瓶颈绝对不在传输中。 我的config.js脚本如下所示: pjs.addSuite({ url: 'http://localhost/file.html'. scraper: function() { var people = $('table.person'); var results = []; $.each(people, function() { var $this = $(this); results.push({ firstName: $this.find('.firstName').text(), lastName: $this.find('.lastName').text(), age: $this.find('.age').text() }); } return results; } } 然后我使用这里的命令行指令来执行PhantomJS。 ~> phantomjs pjscrape.js config.js 我在Chrome中运行相同的代码(只是刮板函数()),它是即时的。 在phantomjs / pjscrape中,需要30秒。 任何线索是什么造成缓慢? 有没有更好的方式来做这个DOM屏幕抓取? 也许一个nodejs解决scheme?

从phantomjs运行摩卡

我只想用Mocha和PhantomJS做一些BDD。 定义一些functionpath并testing它们。 总之,我很想运行命令phantomjs test.js而test.js包含这样的东西: var mocha = require("mocha"); // This one fails with "ReferenceError: Can't find variable: process"….. "/node_modules/mocha/index.js:2" var page = require('webpage').create(); describe('Empty', function(){ // Obviously this one fails too with "ReferenceError: Can't find variable: describe" describe('tests are', function(){ it('very nice', function(done){ page.open("http://www.phantomjs.org/", function (status) { console.log('Loading a web page'); console.log("Page is loaded"); phantom.exit(); […]

使用casperjstestingangularjs应用程序

当使用CaspertestingAngular应用程序时,我发现input和模型之间的绑定似乎没有发生,当我填写表单域。 我用Casper的填充方法,但发现Angular表单validation拒绝任何必填字段,好像它们仍然是空白的。 姓名电子邮件主题信息

教程AngularJS-npm安装错误

我试图按照angularjs网站上的步骤,但我遇到了一个错误。 这是我的package.json的内容: $ cat package.json { "name": "angularjs-seed", "description": "A starter project for AngularJS", "repository": "https://github.com/angular/angular-seed", "devDependencies": { "phantomjs": "~1.9", "karma": "~0.10.4", "karma-junit-reporter": "~0.1", "karma-jasmine": "~0.1.3", "karma-ng-scenario": "~0.1", "karma-chrome-launcher": "~0.1.0", "karma-firefox-launcher": "~0.1.0", "karma-html2js-preprocessor": "~0.1.0", "karma-requirejs": "~0.1.0", "karma-coffee-preprocessor": "~0.1.0", "karma-phantomjs-launcher": "~0.1.0", "karma-script-launcher": "~0.1.0" } } 这是我尝试执行$npm install时的错误 nisevi@nisevi-IdeaPad angular-phonecat (master):$ npm install npm http GET https://registry.npmjs.org/phantomjs […]

Node.js中的HTML到PNG服务器端

我正在寻找一个图书馆采取PNG,把它放在一些HTML,然后重新呈现为一个PNG。 示例代码: var renderingTool = require('renderingTool'); var newPng = renderingTool.pngoutBuffer('' + '<div style="border-left: 12px solid red">' + '<img src="src="data:image/png;base64,iVBORw0KGgoAAA…" />' + '</div>' ); 这将需要一个PNG图像,在左侧添加一个红色的边框,并重新呈现为一个PNG。 我知道Phantom.js和gm(它使用GraphicsMagick)。 我无法弄清楚如何用幻影和GM做到这一点,即使是16像素×16像素的图像(每幅图像250ms),速度也很慢。 我希望能够做到这一点~10毫秒。 编辑: 注:我编辑了上面的代码,以显示原始图像已经在内存中作为缓冲区(在上面我转换为base64)。 另外,幽灵可以给HTML代码,而不是一个URL? 我看到的所有例子都是用URL,但是给出实际的代码会好很多。

在Windows上开发并构build在Linux上的代码上使用NodeJs的Grunt?

如何使用nodejs构build跨平台项目? 我在Windows上开发,但是我的代码库build立在一个基于Linux的CI服务器上。 它使用Grunt构build前端,并且需要几个nodejs模块。 Nodejs需要将模块本地安装到项目中,以便由grunt.task.loadNpmTasks加载。 这个问题是我必须从Windows或Linux的某个地方安装它们,而当我从一个地方安装它时,它不能在另一个地方工作。 我的项目需要的列表模块安装在本地,如下所示: npm install connect-livereload –production npm install time-grunt –production npm install load-grunt-tasks –production npm install jshint-stylish –production npm install load-grunt-tasks –production npm install grunt-contrib-copy –production npm install grunt-contrib-concat –production npm install grunt-contrib-uglify –production npm install grunt-contrib-compass –production npm install grunt-contrib-jshint –production npm install grunt-contrib-cssmin –production npm install grunt-contrib-connect –production npm […]