lapwinglabs / x-ray-phantom

phantom driver for x-ray.
112 stars 30 forks source link

Failing to pass options to nightmare #18

Closed ghostfreak3000 closed 8 years ago

ghostfreak3000 commented 8 years ago

The Usage code snippet.

var phantom = require('x-ray-phantom');
var Xray = require('x-ray');

var x = Xray()
  .driver(phantom());

x('http://google.com', 'title')(function(err, str) {
  if (err) return done(err);
  assert.equal('Google', str);
  done();
})

produces this error. selection_003

Which is basically a XSS scripting security error. so naturally the solution is to disable web security in nightmare... with this code.

var phantom = require('x-ray-phantom');
var Xray = require('x-ray');

var phantom_opts = {
  webPreferences:{
    webSecurity:false
  }
}

var x = Xray()
  .driver(phantom(phantom_opts));

x('https://google.com', 'title')(function(err, str) {
  if (err) return done(err);
  assert.equal('Google', str);
  done();
})

Still produces the same error. Got options structure from here

PS: The phantom process doesn't exit on this error.. not good. anyway we can set it to fail on error?

stpch commented 8 years ago

Try with just var phantom_opts = {webSecurity: false};. Works for me.

ghostfreak3000 commented 8 years ago

It worked... though that means there's a slight difference between the documented options object and the actual one (WIll bite me in the ass when doing advanced crawling in the future)

Thanks alot!