Tag: phantomjs

PhantomJS退出意外退出代码-1073741819

我在Windows 7 PC上用PhantomJS(通过Grunt)运行一些Jasmine规格,而且碰巧遇到以下错误: Testing jasmine specs via phantom …… Running PhantomJS…ERROR >> 0 [ '' ] Warning: PhantomJS exited unexpectedly with exit code -1073741819. Use –force to continue. Aborted due to warnings. 如果我删除一堆testing,错误不会出现; 但是我不知道是什么原因导致错误。 我也觉得奇怪,它只是偶尔发生。 任何想法为什么发生这种情况

setTimeout在Phantom.js中

下面的代码希望Phantom.js加载页面,点击一个button,然后等待5秒钟,然后返回页面的HTML代码。 问题:但是使用setTimeout()创build5秒的延迟会导致page.evaluate函数将null返回给callback函数,而不是HTML。 myUrl = 'http://www.google.com' var phantom = Meteor.npmRequire('phantom') phantom.create = Meteor.wrapAsync(phantom.create) phantom.create( function(ph) { ph.createPage = Meteor.wrapAsync(ph.createPage) ph.createPage(function(page) { page.open = Meteor.wrapAsync(page.open) page.open(listingUrl, function(status) { console.log('Page loaded') page.evaluate = Meteor.wrapAsync(page.evaluate) page.evaluate(function() { // Find the button var element = document.querySelector( '.search-btn' ); // create a mouse click event var event = document.createEvent( 'MouseEvents' ); […]

用phantomjs-node实现waitForfunction

我已经尝试和testing – 成功 – phantomjs示例waitFor 。 但是,我很难通过phantomjs-node模块实现它,主要是因为page.evaluate在callback中被评估。 PhantomJS实现 page.open("http://twitter.com/#!/sencha", function () { waitFor(function() { // This here is easy to do as the evaluate method returns immediately return page.evaluate(function() { return $("#signin-dropdown").is(":visible"); }); }, function() { console.log("The sign-in dialog should be visible now."); phantom.exit(); }); } }); 但是,对于phantomjs-node ,评估函数在callback中获取返回的数据: page.evaluate( function(){ /* return thing */ […]

使用casperjs中的节点模块

是否可以安装通过npm安装的节点模块,然后从casperjs脚本中获取? (我看到很多post和工具,用于在node.js中运行casper或phantom,但这不是我想要做的。) casperjs文档似乎说这是可能的,但只能用手写的玩具模块来展示,而这些模块并不真正做任何事情。 我试图安装的真实世界的模块是imap ,但在这一点上,我不能得到任何模块的工作,即使内置的net 。 简单的例子: npm install imap echo "var test = require('imap');" > test.js casperjs test.js 给我: CasperError: Can't find module imap /usr/local/src/casperjs/bin/bootstrap.js:263 in patchedRequire test.js:1 (我可以从npm ls看到imap模块,我可以从node.js脚本中使用它)。 或者使用内置模块: echo "var test = require('net');" > test.js casperjs test.js 抱怨“找不到模块网” 我有npm –version 1.4.14和nodejs –version v0.10.29。 那些太旧了,我想知道? (Casper是1.1.0-beta,Phantom是1.9.7,两者都是最新版本。)

Phantomjs不会在page.evaluate函数中执行函数

我正在使用PhantomJS节点模块( https://github.com/sgentle/phantomjs-node )来抓取Facebook页面,但是当我尝试评估页面时,它并没有评估我传递给它的函数。 在一个独立的脚本中执行它,并使用Node解释器运行它。Express.js应用程序中的相同代码不起作用。 这是我的代码 facebookScraper.prototype.scrapeFeed = function (url, cb) { f = ':scrapeFeed:'; var evaluator = function (s) { var posts = []; for (var i = 0; i < FEED_ITEMS; i++) { log.info(__filename+f+' iterating step ' + i); log.info(__filename+f+util.inspect(document, false, null)); } return { news: posts }; } phantom.create(function (ph) { ph.createPage(function (page) […]

phantomjs +网页字体+字体加载器

我在node.js环境中运行phantomjs ,并且进展顺利。 目前,我只是使用本地字体,但希望获得谷歌网页字体与phantomjs工作。 关于networking字体是否以及如何与phantomjs一起工作,有各种相互矛盾和混淆的报道。 有这样的文章包含过时的信息与死链接。 而像这样的post表明, phantomjs 2.0将会或可以支持网页字体,其他人则认为它不会但2.0.1会。 在这篇文章中有一个build议,webfonts在2.0工作。 我已经尝试了很多select,包括与phantomjs 2.0和2.0.1二进制文件,但不能得到它的工作。 这可能是因为我正在使用Web字体加载器使用以下内容来加载我的js中的Web字体 : WebFont.load({ google: { families: ['Droid Sans', 'Droid Serif'] }, loading: function() { console.log('loading'); }, active: function() { console.log('active'); // hooray! can do stuff… }, inactive: function() { console.log('inactive'); }, fontloading: function(familyName, fvd) { console.log('fontloading', familyName, fvd); }, fontactive: function(familyName, fvd) { console.log('fontactive', […]

无法在Heroku上运行Phantomjs +节点

我已经成功地让Phantomjs能够在Heroku上工作,但现在我遇到了node.js的phantomjs-node接口问题(请参阅https://github.com/sgentle/phantomjs-node )。 当我试图初始化幻影时,我看到一个10-15秒的延迟,然后: > phantom stdout: ReferenceError: Can't find variable: socket phantom stdout: phantomjs://webpage.evaluate():1 phantomjs://webpage.evaluate():1 phantomjs://webpage.evaluate():1 您可以通过以下步骤重现问题,或通过在https://github.com/matellis/phantom-test下拉testing应用程序 git init phantom-test cd phantom-test heroku apps:create # create node app as per Heroku instructions here https://devcenter.heroku.com/articles/nodejs # copy bin and lib folders from http://phantomjs.googlecode.com/files/phantomjs-1.6.1-linux-x86_64-dynamic.tar.bz2 into root of your new project # if you don't do this step […]

量angular器在PhantomJS上运行testing

我似乎无法成功通过testingPhantomJS。 我试图将其整合到我的项目中,但之后失败了,我试图运行基本的Angular Docs样本,并得到同样的问题。 我到目前为止的步骤: npm install -g phantomjs phantomjs –webdriver=9515 // … GhostDriver – Main – 在端口9515上运行 protractor protractorConf.js 这是与仅有browserName和seleniumAddress端口更改相同的文件: // An example configuration file. exports.config = { // The address of a running selenium server. seleniumAddress: 'http://localhost:9515', // Capabilities to be passed to the webdriver instance. capabilities: { 'browserName': 'phantomjs' }, // Spec patterns […]

在node.js中使用“网页”幻影模块

我想在一个node.js过程中包装一个PhantomJS脚本。 幻影脚本从命令行提供的参数中获取一个url,并输出一个pdf(与pahntom安装中包含的rasterize.js示例非常相似)。 我的幻影脚本工作正常,这只是我的雇主希望如果可能的节点脚本。 没问题,我可以使用node-phantom节点模块来包装它。 但是现在我碰到了一个绊脚石,我的幻影脚本有: var page = require('webpage').create(); 因此,node.js试图find一个名为“网页”的模块,“网页”模块内置到幻影安装中,因此节点找不到它。 据我所知,没有npm模块叫做“网页”。 '网页'是这样使用的: page.open(address, function (status) { if (status !== 'success') { // — Error opening the webpage — console.log('Unable to load the address!'); } else { // — Keep Looping Until Render Completes — window.setTimeout(function () { page.render(output); phantom.exit(); }, 200); } }); 其中address是在命令行中指定的url,output是另一个参数,即文件的名称和types。 谁能帮我吗? […]

如何使用NodeJS在AWS Lambda上运行PhantomJS

在互联网上的其他地方找不到工作答案之后,我正在提交这个问答本人教程 我如何从AWS Lambda上的NodeJS脚本获得一个简单的PhantomJS进程? 我的代码在我的本地机器上工作正常,但遇到了不同的问题,试图在Lambda上运行它。