{"_id":"352-phantom","_rev":"7-646ba7dcf293efb501e4d14032714a6c","name":"352-phantom","description":"PhantomJS wrapper for Node","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"author":{"name":"Sam Gentle","email":"sam@samgentle.com"},"name":"352-phantom","description":"PhantomJS wrapper for Node","homepage":"https://github.com/sgentle/phantomjs-node","version":"0.0.1","repository":{"type":"git","url":"git://github.com/sgentle/phantomjs-node.git"},"contributors":[{"name":"Amir Raminfar","email":"findamir@gmail.com"}],"main":"phantom.js","engines":{"node":">=v0.8.0"},"dependencies":{"dnode":"~1.2.0","shoe":"~0.0.10","win-spawn":"~2.0.0","traverse":"~0.6.3"},"devDependencies":{"browserify":"1.10.9","coffee-script":"~1.7.1","express":"3.2.5","temp":"~0.4.0","ps-tree":"~0.0.2","vows":"~0.7.0","bluebird":"~1.2.3","phantomjs":"~1.9.7-5"},"licenses":{"type":"MIT","url":"http://www.opensource.org/licenses/MIT"},"scripts":{"test":"cake test"},"bugs":{"url":"https://github.com/sgentle/phantomjs-node/issues"},"directories":{"test":"test"},"keywords":["phantomjs"],"license":"ISC","gitHead":"7596b209780068f9dd2ebfb091cf9e066c18e242","_id":"352-phantom@0.0.1","_shasum":"4fd2b15e931456c2b1f3b71ab1650dd4d80aceda","_from":"./","_npmVersion":"1.4.23","_npmUser":{"name":"dvideby0","email":"rbrookfield@352inc.com"},"maintainers":[{"name":"dvideby0","email":"rbrookfield@352inc.com"}],"dist":{"shasum":"4fd2b15e931456c2b1f3b71ab1650dd4d80aceda","tarball":"https://registry.npmjs.org/352-phantom/-/352-phantom-0.0.1.tgz","integrity":"sha512-4F5HPcjsIe1Z1B+2JPjGfCvBGsq5JN7IlZqNA+o4vkxs691dx9z7UnGzzrJJJwGlnkt43xnK56CNuEssvEw3eA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAJ4Y4TLbeWFx7mClr8OTl0h3yB1G/N+dlQJ3K4P/XDWAiEAmsFenTE9CCApcGOH1Br/uwpdVFspocShcRIuzdYdGT8="}]}},"0.0.2":{"author":{"name":"Sam Gentle","email":"sam@samgentle.com"},"name":"352-phantom","description":"PhantomJS wrapper for Node","homepage":"https://github.com/sgentle/phantomjs-node","version":"0.0.2","repository":{"type":"git","url":"git://github.com/dvideby0/phantomjs-node.git"},"contributors":[{"name":"Amir Raminfar","email":"findamir@gmail.com"}],"main":"phantom.js","engines":{"node":">=v0.8.0"},"dependencies":{"dnode":"~1.2.0","shoe":"~0.0.10","win-spawn":"~2.0.0","traverse":"~0.6.3"},"devDependencies":{"browserify":"1.10.9","coffee-script":"~1.7.1","express":"3.2.5","temp":"~0.4.0","ps-tree":"~0.0.2","vows":"~0.7.0","bluebird":"~1.2.3","phantomjs":"~1.9.7-5"},"licenses":{"type":"MIT","url":"http://www.opensource.org/licenses/MIT"},"scripts":{"test":"cake test"},"bugs":{"url":"https://github.com/sgentle/phantomjs-node/issues"},"directories":{"test":"test"},"keywords":["phantomjs"],"license":"ISC","gitHead":"7596b209780068f9dd2ebfb091cf9e066c18e242","_id":"352-phantom@0.0.2","_shasum":"0999fd81ed8401b30640a4f8d566d954a7f52682","_from":"./","_npmVersion":"1.4.23","_npmUser":{"name":"dvideby0","email":"rbrookfield@352inc.com"},"maintainers":[{"name":"dvideby0","email":"rbrookfield@352inc.com"}],"dist":{"shasum":"0999fd81ed8401b30640a4f8d566d954a7f52682","tarball":"https://registry.npmjs.org/352-phantom/-/352-phantom-0.0.2.tgz","integrity":"sha512-tM0lfuUqVuhtcYCGHu3Azne9H6iu/CJgkTNrz9uc2r0xXQsAphPHeaMkp3kY6hBn9+u/6gntLNBzvFDPaaD9gQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDqt3RCVkebktx/XE4tk8kEwih5uMV7+Fuq4u3CCjx4TAIhAK5O8K5AQGWV2OEeruGoBYNyiHxJuOSEo9H5U2I4hkie"}]}},"0.0.3":{"author":{"name":"Sam Gentle","email":"sam@samgentle.com"},"name":"352-phantom","description":"PhantomJS wrapper for Node","homepage":"https://github.com/dvideby0/phantomjs-node","version":"0.0.3","repository":{"type":"git","url":"git://github.com/sgentle/phantomjs-node.git"},"contributors":[{"name":"Amir Raminfar","email":"findamir@gmail.com"}],"main":"phantom.js","engines":{"node":">=v0.8.0"},"dependencies":{"dnode":"~1.2.0","shoe":"~0.0.10","win-spawn":"~2.0.0","traverse":"~0.6.3"},"devDependencies":{"browserify":"1.10.9","coffee-script":"~1.7.1","express":"3.2.5","temp":"~0.4.0","ps-tree":"~0.0.2","vows":"~0.7.0","bluebird":"~1.2.3","phantomjs":"~1.9.7-5"},"licenses":{"type":"MIT","url":"http://www.opensource.org/licenses/MIT"},"scripts":{"test":"cake test"},"gitHead":"7596b209780068f9dd2ebfb091cf9e066c18e242","bugs":{"url":"https://github.com/sgentle/phantomjs-node/issues"},"_id":"352-phantom@0.0.3","_shasum":"c78848112f85b96d7b379e3a598bd21dc85f7c79","_from":".","_npmVersion":"2.7.5","_nodeVersion":"0.10.31","_npmUser":{"name":"dvideby0","email":"rbrookfield@352inc.com"},"maintainers":[{"name":"dvideby0","email":"rbrookfield@352inc.com"}],"dist":{"shasum":"c78848112f85b96d7b379e3a598bd21dc85f7c79","tarball":"https://registry.npmjs.org/352-phantom/-/352-phantom-0.0.3.tgz","integrity":"sha512-UA86m+ZijbgiKdX7kl9qSc3nMID3eUoxty/XtxLNenyQtIiJXffPTV+gnuQ0fSLDN7LPeWLxqqHs0kI6KMtcbg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBccFPBsiY8e7HUoOuInY6wC63WbLyjK/u3uuUsy/89gAiEAqoeFyKsYnGXfui0u05nC3w/5q6l/+4sT/CxfRz4spB0="}]}}},"readme":"# PhantomJS bridge for NodeJS [![Build Status](https://travis-ci.org/sgentle/phantomjs-node.svg?branch=master)](https://travis-ci.org/sgentle/phantomjs-node)\n\n\"It sure would be neat if [PhantomJS](http://www.phantomjs.org/) was a NodeJS module\", I hear you say. Well, wait no longer! This node module implements a nauseously clever bridge between Phantom and Node, so that you can use all your favourite PhantomJS functions without leaving NPM behind and living in a cave.\n\n## Installation\n\nFirst, make sure PhantomJS is installed. This module expects the ```phantomjs``` binary to be in PATH somewhere. In other words, type this:\n\n    $ phantomjs\n\nIf that works, so will phantomjs-node. It's only been tested with PhantomJS 1.3, and almost certainly doesn't work with anything older.\n\nInstall it like this:\n\n    npm install phantom\n\n\nFor a brief introduction continue reading, otherwise **go to the [Wiki page](https://github.com/sgentle/phantomjs-node/wiki) for more information!**\n\n\n## How do I use it?\n\nUse it like this in Coffeescript:\n\n```coffeescript\nphantom = require 'phantom'\n\nphantom.create (ph) ->\n  ph.createPage (page) ->\n    page.open \"http://www.google.com\", (status) ->\n      console.log \"opened google? \", status\n      page.evaluate (-> document.title), (result) ->\n        console.log 'Page title is ' + result\n        ph.exit()\n```\n\nIn Javascript:\n\n```js\nvar phantom = require('phantom');\n\nphantom.create(function (ph) {\n  ph.createPage(function (page) {\n    page.open(\"http://www.google.com\", function (status) {\n      console.log(\"opened google? \", status);\n      page.evaluate(function () { return document.title; }, function (result) {\n        console.log('Page title is ' + result);\n        ph.exit();\n      });\n    });\n  });\n});\n```\n\n### Use it in Windows\n\nIt would use `dnode` with `weak` module by default. It means that you need to setup `node-gyp` with Microsoft VS2010 or VS2012, which is a huge installation on Windows.\n\n`dnodeOpts` property could help you to control dnode settings, so you could disable `weak` by setting it `false` to avoid that complicated installations.\n\n```js\nvar phantom = require('phantom');\n\nphantom.create(function (ph) {\n  ph.createPage(function (page) {\n    /* the page actions */\n  });\n}, {\n  dnodeOpts: {\n    weak: false\n  }\n});\n```\n\n### Use it in restricted enviroments\n\nSome enviroments (eg. [OpenShift](https://help.openshift.com/hc/en-us/articles/202185874-I-can-t-bind-to-a-port)) have special requirements that are difficult or impossible to change, especifficaly: hostname/ip and port restrictions for the internal communication server and path for the phantomjs binary.\n\nBy default, the hostname/ip used for this will be `localhost`, the port will be port `0` and the phantomjs binary is going to be assumed to be in the `PATH` enviroment variable, but you can use specific configurations using an `options` object like this:\n\n```js\nvar options = {\n  port: 16000,\n  hostname: \"192.168.1.3\",\n  path: \"/phantom_path/\"\n}\n\nphantom.create(function, options);\n```\n\n## Functionality details\n\nYou can use all the methods listed on the [PhantomJS API page](http://phantomjs.org/api/)\n\n\nDue to the async nature of the bridge, some things have changed, though:\n\n* Return values (ie, of ```page.evaluate```) are returned in a callback instead\n* ```page.render()``` takes a callback so you can tell when it's done writing the file\n* Properties can't be get/set directly, instead use ```page.get('version', callback)``` or ```page.set('viewportSize', {width:640,height:480})```, etc. Nested objects can be accessed by including dots in keys, such as ```page.set('settings.loadImages', false)```\n* Callbacks can't be set directly, instead use ```page.set('callbackName', callback)```, e.g. ```page.set('onLoadFinished', function(success) {})```\n* onResourceRequested takes a function that executes in the scope of phantom which has access to ```request.abort()```, ```request.changeUrl(url)```, and ```request.setHeader(key,value)```. The second argument is the callback which can execute in the scope of your code, with access to just the requestData. e.g.\n```\npage.onResourceRequested(\n\tfunction(requestData, request) { request.abort(); },\n\tfunction(requestData) { console.log(requestData.url) }\n);\n```\n\n```ph.createPage()``` makes new PhantomJS WebPage objects, so use that if you want to open lots of webpages. You can also make multiple phantomjs processes by calling ```phantom.create('flags', { port: someDiffNumber})``` multiple times, so if you need that for some crazy reason, knock yourself out!\n\nAlso, you can set exit callback, which would be invoked after ```phantom.exit()``` or after phantom process crash:\n```\nphantom.create('flags', { port: 8080, onExit: exitCallback})\n```\n\nYou can also pass command line switches to the phantomjs process by specifying additional args to ```phantom.create()```, eg:\n\n```coffeescript\nphantom.create '--load-images=no', '--local-to-remote-url-access=yes', (page) ->\n```\n\nor by specifying them in the options object:\n\n```coffeescript\nphantom.create {parameters: {'load-images': 'no', 'local-to-remote-url-access': 'yes'}}, (page) ->\n```\n\nIf you need to access the [ChildProcess](http://nodejs.org/api/child_process.html#child_process_class_childprocess) of the phantom process to get its PID, for instance, you can access it through the `process` property like this:\n```\nphantom.create(function (ph) {\n  console.log('phantom process pid:', ph.process.pid);\n});\n```\n\n##Note for Mac users\n\nPhantom requires you to have the XCode Command Line Tools installed on your box, or else you will get some nasty errors (`xcode` not found or `make` not found).  If you haven't already, simply install XCode through the App Store, then [install the command line tools](http://stackoverflow.com/questions/6767481/where-can-i-find-make-program-for-mac-os-x-lion).  \n\n## How does it work?\n\nDon't ask. The things these eyes have seen.\n\n## No really, how does it work?\n\nI will answer that question with a question. How do you communicate with a process that doesn't support shared memory, sockets, FIFOs, or standard input?\n\nWell, there's one thing PhantomJS does support, and that's opening webpages. In fact, it's really good at opening web pages. So we communicate with PhantomJS by spinning up an instance of ExpressJS, opening Phantom in a subprocess, and pointing it at a special webpage that turns socket.io messages into ```alert()``` calls. Those ```alert()``` calls are picked up by Phantom and there you go!\n\nThe communication itself happens via James Halliday's fantastic [dnode](https://github.com/substack/dnode) library, which fortunately works well enough when combined with [browserify](https://github.com/substack/node-browserify) to run straight out of PhantomJS's pidgin Javascript environment.\n\nIf you'd like to hack on phantom, please do! You can run the tests with ```cake test``` or ```npm test```, and rebuild the coffeescript/browserified code with ```cake build```. You might need to ```npm install -g coffee-script``` for cake to work.\n","maintainers":[{"name":"dvideby0","email":"rbrookfield@352inc.com"}],"time":{"modified":"2022-06-12T14:07:13.229Z","created":"2014-12-09T19:09:56.789Z","0.0.1":"2014-12-09T19:09:56.789Z","0.0.2":"2014-12-09T19:15:54.209Z","0.0.3":"2015-06-18T15:38:21.188Z"},"homepage":"https://github.com/dvideby0/phantomjs-node","repository":{"type":"git","url":"git://github.com/sgentle/phantomjs-node.git"},"contributors":[{"name":"Amir Raminfar","email":"findamir@gmail.com"}],"author":{"name":"Sam Gentle","email":"sam@samgentle.com"},"bugs":{"url":"https://github.com/sgentle/phantomjs-node/issues"},"readmeFilename":"README.markdown"}