Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant get it to work with phantomjs #10

Open
kitkat14 opened this issue Jul 17, 2015 · 9 comments
Open

Cant get it to work with phantomjs #10

kitkat14 opened this issue Jul 17, 2015 · 9 comments

Comments

@kitkat14
Copy link

When I am using phantomjs without xray it works great.

When I am using the example:

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();
})

and run it with phantomjs test.js

I get the following error:

Error: Cannot find module 'tty'

phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254 in require
C:/Users/Gebruiker/node_modules/x-ray-phantom/node_modules/debug/node.js:6
C:/Users/Gebruiker/node_modules/x-ray-phantom/node_modules/debug/node.js:210
TypeError: '[object Object]' is not a function (evaluating 'require('debug')('x-
ray:phantom')')

C:/Users/Gebruiker/node_modules/x-ray-phantom/index.js:5
C:/Users/Gebruiker/node_modules/x-ray-phantom/index.js:93
TypeError: 'undefined' is not a function (evaluating 'phantom.loadModule(code, t
his.filename)')

phantomjs://bootstrap.js:272
phantomjs://bootstrap.js:125
phantomjs://bootstrap.js:268
phantomjs://bootstrap.js:301
phantomjs://bootstrap.js:254 in require
phantest.js:2

@zipzit
Copy link

zipzit commented Feb 18, 2016

I'm seeing nearly the same errors.

$ phantomjs scrape.js
Error: Cannot find module 'tty'

  phantomjs://platform/bootstrap.js:299 in require
  phantomjs://platform/bootstrap.js:263 in require
  phantomjs://platform/node.js:7
TypeError: Object is not a constructor (evaluating 'require('debug')('x-ray:phantom')')

  phantomjs://platform/index.js:6
TypeError: undefined is not a constructor (evaluating 'phantom.loadModule(code, this.filename)')

  phantomjs://platform/bootstrap.js:282 in _compile
  phantomjs://platform/bootstrap.js:126 in .js
  phantomjs://platform/bootstrap.js:278 in _load
  phantomjs://platform/bootstrap.js:311 in require
  phantomjs://platform/bootstrap.js:263 in require

I can use node and x-ray to look at static webpages. I really like the x-ray interface. Unfortunately for dynamically created content, that just won't work. I'm at a loss. I'm guessing this entire module was written to take advantage of a phantomjs wrapper (sockets?) but phantomjs in its current form doesn't support?

Er, wait just a moment! does this module require https://github.com/amir20/phantomjs-node (PhantomJS integration module for NodeJS, I would call this a Bridge module..and its installed via npm install phantom) or does it require phantomjs (downloaded from http://phantomjs.org/)?? That phantomjs.org tool is not written as a node module, its a pure standalone. I'm using the pure standalone tool (per my $phantomjs scrape.js code above...)

Suggestion: What ever the right tools are, can we get a hint added to the readme.md page to tell us what's what?

@stephengardner
Copy link

@zipzit Did you solve this?

@zipzit
Copy link

zipzit commented Mar 1, 2016

Er, no.. When you hit a brick wall, turn right. I was never able to understand when I'm running Phantom as a tool (like NPM or Node) or as a module. Frankly I'm new to this game, and I got lost in the different versions of what supports what. For my project, I'm lucky in that the data I'm scraping is generated static from the server. I was hoping to write a generic tool that would allow me to scrape JavaScript deployed content on a page, and I was hoping to use this tool to gain a bit of understanding. I failed.

@stephengardner
Copy link

I just fixed this by installing from phantomjs.org. Add the /bin folder to your system PATH. I guess the standalone is required by the npm module. The npm module runs the "phantom" command from your PATH.

@Xsmael
Copy link

Xsmael commented Jun 2, 2016

Can you please details how exactly you solved it ? i have similar problem, trying to run PhantomJS with a logging module (https://github.com/Xsmael/node-logger) which bin folder is did you add to the PATH ? and what is that "standalone" ?

@jiawenzhang
Copy link

jiawenzhang commented Aug 18, 2016

This module has anything to do with phantomjs. If you look at its code, it uses Nightmare which uses Electron underneath. Electron is an alternative to phantoms.

Actually, Nightmare used to depend on phantomjs, but they switched to Electron.

@rohmanhm
Copy link

rohmanhm commented Feb 12, 2017

I had the same problem in here.

@ashiquemohammed
Copy link

Same for me .

@ugurcemozturk
Copy link

ugurcemozturk commented Nov 17, 2017

Same here. Trying to use with deathbycaptcha module. Gives the following errors:
Error: Cannot find module 'events' phantomjs:/platform/bootstrap.js:299 in require phantomjs:/platform/bootstrap.js:263 in require phantomjs:/platform/deathbycaptcha.js:8 phantomjs:/platform/deathbycaptcha.js:165 TypeError: Object is not a constructor (evaluating 'new DeathByCaptcha("xxx", "xxx")') /phantomjs:/code/saveCaptcha.js:20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants