node-tarantula icon indicating copy to clipboard operation
node-tarantula copied to clipboard

PhantomJS leg TypeError: Cannot read property 'map' of null

Open DenJohX opened this issue 9 years ago • 0 comments

When using the PhantomJS leg it fails with that error

For example, with this code:

#!/usr/bin/env node
var Tarantula = require('tarantula');

var brain = {
    leg: 'PhantomJS',
    legs: 2,

    shouldVisit: function(uri) {
        return true;
    }

};

var tarantula = new Tarantula(brain);

tarantula.on('data', function (uri) {
      console.info('200', uri);
});

tarantula.on('done', function() { 
    console.log('done'); 
});

tarantula.start(["http://stackoverflow.com"]);

results in this error:

$ node-debug index.js
Node Inspector is now available from http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858
Debugging `index.js`

Debugger listening on port 5858
TypeError: Cannot read property 'map' of null
    at EventEmitter.Tarantula.push (/home/dennis/workspace/offline-remastered/crawler/node_modules/tarantula/lib/tarantula.js:158:14)
    at EventEmitter.<anonymous> (/home/dennis/workspace/offline-remastered/crawler/node_modules/tarantula/lib/tarantula.js:73:8)
    at emitThree (events.js:102:20)
    at EventEmitter.emit (events.js:175:7)
    at EventEmitter.Tarantula.legEvent (/home/dennis/workspace/offline-remastered/crawler/node_modules/tarantula/lib/tarantula.js:269:12)
    at /home/dennis/workspace/offline-remastered/crawler/node_modules/tarantula/lib/client/PhantomClient.js:202:19
    at /home/dennis/workspace/offline-remastered/crawler/node_modules/tarantula/lib/client/PhantomClient.js:233:4
    at /home/dennis/workspace/offline-remastered/crawler/node_modules/tarantula/node_modules/node-phantom-simple/node-phantom-simple.js:40:26
    at IncomingMessage.<anonymous> (/home/dennis/workspace/offline-remastered/crawler/node_modules/tarantula/node_modules/node-phantom-simple/node-phantom-simple.js:455:17)
    at emitNone (events.js:72:20)

PhantomJS is installed from the website, and is in the PATH:

$ whereis phantomjs
phantomjs: /usr/bin/phantomjs /usr/local/bin/phantomjs

Any ideas on how to make it work? Thanks.

DenJohX avatar Dec 29 '15 23:12 DenJohX