Tag: spookyjs

如何在SpookyJS中注入脚本?

我正在尝试在我的SpookyJS程序中注入punycode脚本。 但它不工作。 try { var Spooky = require('spooky'); } catch (e) { var Spooky = require('../lib/spooky'); } var spooky = new Spooky({ child: { transport: 'http' }, casper: { logLevel: 'debug', verbose: true, options: { clientScripts: ["punycode.js"] } } }, function (err) { if (err) { e = new Error('Failed to initialize SpookyJS'); e.details = […]

ReferenceError:用SpookyJS找不到variables

我尝试在SpookyJS中调用外部函数,方法与在wiki中执行相同的操作: https : //github.com/WaterfallEngineering/SpookyJS/wiki/Introduction 但是,当我尝试下面的代码,我有这个错误: ReferenceError:找不到variables:test try { var Spooky = require('spooky'); } catch (e) { var Spooky = require('../lib/spooky'); } var urls = ["http://www.google.fr", "http://www.yahoo.com" ]; exports.clicker = function(req, res) { console.log("FIRST: " + visitUrl + " \n\n\n END FIRST"); var visitUrl = function(urlIndex, nbClicked) { console.log("HELLO"); }; var spooky = new Spooky( { […]

了解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 = […]

SpookyJS在meteor中使用时没有启动方法

我有一个奇怪的错误,无法find过去几个小时的原因… 我有一个meteor的应用程序,这刮了一些网页的信息,一切正常,只要我使用reuqest和cheerio静态页面,但现在我有一个dynamic的网站,我想要使用phantomjs,casperjs和spookyjs这个,但在这里我得到一些错误…我的代码如下,我在开始时导入npm模块: if (Meteor.isServer) { var cheerio = Meteor.npmRequire('cheerio'); var request = Meteor.npmRequire('request'); var phantomJS = Meteor.npmRequire('phantomjs'); var spooky = Meteor.npmRequire('spooky'); 有时候,我想用怪异的东西来刮一些网页: spooky.start("https://www.coursera.org/"); spooky.then( function () { this.fill("form", {email: user, password: pass}, true); });` 但只要我调用方法,我得到以下错误信息: 20150224-21:16:39.100(-5)? Exception while invoking method 'getLecturesCoursera' TypeError: Object function Spooky(options, callback) { …. I20150224-21:16:39.281(-5)? } has no method 'start' I20150224-21:16:39.281(-5)? […]

将值从spookyjs环境存储到mongoDB

我试图通过spookyjs从网站上刮取数据,并存储在mongoDB中 。我能够从网站获取数据。但不能保存从spookyjs环境中刮取的数据到mongoDB。为了保存刮取的数据,我将我的数据库模型实例spookyjs。我在下面的链接中提到它。 https://github.com/SpookyJS/SpookyJS/wiki/Introduction 以下是我在prod_link_infovariables中提取数据并将其值传递给mongoDB的代码 var product_model = require('./product').product_model; //get results spooky.then([{product_model:product_model},function(){ this.waitForSelector('li[id^="product_"]', function() { // Get info on all elements matching this CSS selector var prod_link_info = this.evaluate(function() { var nodes = document.querySelectorAll('li[id^="product_"]'); return [].map.call(nodes, function(node) { // Alternatively: return Array.prototype.map.call(… return node.querySelector('a').getAttribute('href')+"\n"; }); }); //insert values in mongodb for (var i = 0; i […]

在AWS弹性beanstalk上产生casperjs ENOENT错误

我正在试图使用SPOOKY在nodejs上运行casper scraper。 当我在本地主机上运行时,scrapper工作正常,但是当我在AWS elastic beanstalk服务器上部署项目时,出现以下错误。 Error: spawn casperjs ENOENT at exports._errnoException (util.js:1018:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) at onErrorNT (internal/child_process.js:367:16) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) [nodemon] app crashed – waiting for file changes before starting… 我已经尝试设置binPath: './node_modules/casperjs/bin/casperjs'"并试图在全球范围内安装Casper,但无法执行此操作,还添加了command: /^win/.test(process.platform) ? 'casperjs.cmd' : 'casperjs',给孩子,但是也没有成功。 我一直在寻找这一个多星期,但没有成功。 请帮我解决这个问题。

使用Spooky.js运行示例代码时出错

我是新来的整个phantom.js , casper.js , casper.js和spooky.js 。 我已经安装了所有的东西(在Windows中),更新PATH并遵循这个例子: https://github.com/WaterfallEngineering/SpookyJS 我得到这个错误: C:\node_modules\spooky>node examples/hello.js events.js:68 throw arguments[1]; // Unhandled 'error' event ^ Error: Child terminated with non-zero exit code 127 at Spooky._spawnChild.Spooky._instances.(anonymous function) (C:\node_module s\spooky\lib\spooky.js:82:17) at ChildProcess.EventEmitter.emit (events.js:96:17) at Process._handle.onexit (child_process.js:678:10) 任何人有任何线索为什么和如何解决它? 我运行casperjs googlelinks.js就好了。 但是使用node.js和spooky.js ,这给我带来了麻烦。

如何调用SpookyJS中的函数?

我有一个叫做clickMore的函数: function clickMore(max, i){ i = i || 0; if ((max == null || i < max) && this.visible(moreButton)) { // synchronous // asynchronous steps… this.thenClick(moreButton); // sometimes the click is not properly dispatched this.echo('click'); this.waitUntilVisible(loadingButton); this.waitUntilVisible(moreButton, null, function onTimeout(){ // only placeholder so that the script doesn't "die" here if the end is reached […]

减less无限循环中的phantomjs / casperjs / spookyjs内存使用

我试图刮一个页面,使用phantomjs casperjs和幽灵般的无限滚动。 它应该继续点击更多的button,并从结果中的新链接,直到手动停止。 然而脚本开始使用越来越多的内存,直到它崩溃。 我写了下面的脚本,有没有一种方法来优化它,所以它不会使用更多的内存: function pressMore(previousLinksLength) { this.click('#projects > div.container-flex.px2 > div > a'); this.wait(1000, function() { links = this.evaluate(function() { var projectPreview = document.querySelectorAll('.project-thumbnail a'); return Array.prototype.map.call(projectPreview, function(e) { return e.getAttribute('href'); }); }); this.emit('sendScrapedLinks', links.slice(previousLinksLength)); // repeat scrape function pressMore.call(this, links.length); }); } // spookyjs starts here spooky.start(scrapingUrl); //press the more button spooky.then(pressMore); […]

如何在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是: […]