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)? at [object Object].Meteor.methods.getLecturesCoursera (app/moocis.js:72:14) 

我正在做一些完全错误的,我不知道为什么它不工作…我试图validationspookyjs和phantomjs正确安装在我的应用程序,但是这不是那么容易,因为听起来有人谁使用它们首次…

像通常与幽灵,你必须创build一个新的Spooky对象,然后才能启动和运行它…

  if (Meteor.isServer) { Meteor.startup( function () { var Spooky = Meteor.npmRequire('spooky'); var spooky = new Spooky({ child: { transport: 'http' }, casper: { logLevel: 'debug', verbose: true, ignoreSslErrors: true, sslProtocol: 'tlsv1' } }, function (err) { if (err) { e = new Error('Failed to initialize SpookyJS'); e.details = err; throw e; } spooky.start( 'https://www.google.com'); spooky.then(function () { this.emit('hello', 'Hello, from ' + this.evaluate(function () { return document.title; })); }); spooky.run(); }); spooky.on('error', function (e, stack) { console.error(e); if (stack) { console.log(stack); } }); spooky.on('hello', function (greeting) { console.log(greeting); }); spooky.on('log', function (log) { if (log.space === 'remote') { console.log(log.message.replace(/ \- .*/, '')); } }); }) }