{"bugs":{"url":"https://github.com/alexscheelmeyer/node-phantom/issues"},"dist":{"shasum":"e330c3c4f6e7564aeec838a61afb0bd70e9c17ab","tarball":"https://registry.npmjs.org/node-phantom/-/node-phantom-0.2.5.tgz","integrity":"sha512-Kg229G3NeweBQWdVcyATUxwvklsCVvbs7d+F01pxacP220k7qji33mTqYdoa7W88V1/Nt0oJbJ0J5WJyPy5X0g==","signatures":[{"sig":"MEUCIH2Yn//yym6UyU4EwVg2ladtjpiQ4LUU+FMiV0X85zdKAiEA/+v6zHccpv458r/iQXeYL3JMNTGfbY740e0t5tp73UI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"node-phantom.js","name":"node-phantom","_from":".","author":{"url":"http://www.linkedin.com/in/alexscheelmeyer","name":"Alex Scheel Meyer"},"readme":"Node-phantom\n---------------\n\nThis is a bridge between [PhantomJs](http://phantomjs.org/) and [Node.js](http://nodejs.org/).\n\nIt is very much similar to the other bridge available, [PhantomJS-Node](https://github.com/sgentle/phantomjs-node), but is different in a few ways:\n\n  - Way fewer dependencies/layers.\n  - API has the idiomatic error indicator as first parameter to callbacks.\n  - Uses plain Javascript instead of Coffeescript.\n\n\nRequirements\n------------\nYou will need to install PhantomJS first. The bridge assumes that the \"phantomjs\" binary is available in the PATH.\n\nThe only other dependency for using it is [socket.io](http://socket.io/).\n\nFor running the tests you will need [Mocha](http://visionmedia.github.io/mocha/). The tests require PhantomJS 1.6 or newer to pass.\n\n\nInstalling\n----------\n\n    npm install node-phantom\n\n\nUsage\n-----\nYou can use it pretty much like you would use PhantomJS-Node, for example this is an adaptation of a [web scraping example](http://net.tutsplus.com/tutorials/javascript-ajax/web-scraping-with-node-js/) :\n\n```javascript\nvar phantom=require('node-phantom');\nphantom.create(function(err,ph) {\n  return ph.createPage(function(err,page) {\n    return page.open(\"http://tilomitra.com/repository/screenscrape/ajax.html\", function(err,status) {\n      console.log(\"opened site? \", status);\n      page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', function(err) {\n        //jQuery Loaded.\n        //Wait for a bit for AJAX content to load on the page. Here, we are waiting 5 seconds.\n        setTimeout(function() {\n          return page.evaluate(function() {\n            //Get what you want from the page using jQuery. A good way is to populate an object with all the jQuery commands that you need and then return the object.\n            var h2Arr = [],\n            pArr = [];\n            $('h2').each(function() {\n              h2Arr.push($(this).html());\n            });\n            $('p').each(function() {\n              pArr.push($(this).html());\n            });\n\n            return {\n              h2: h2Arr,\n              p: pArr\n            };\n          }, function(err,result) {\n            console.log(result);\n            ph.exit();\n          });\n        }, 5000);\n      });\n\t});\n  });\n});\n```\n\n### phantom.create(callback,options)\n\n`options` is an optional object with options for how to start PhantomJS.\n`options.parameters` is an array of parameters that will be passed to PhantomJS on the commandline.\nFor example\n\n```javascript\nphantom.create(callback,{parameters:{'ignore-ssl-errors':'yes'}})\n```\n\nwill start phantom as:\n\n```bash\nphantomjs --ignore-ssl-errors=yes\n```\n\nYou may also pass in a custom path if you need to select a specific instance of PhantomJS or it is not present in PATH environment.\nThis can for example be used together with the [PhantomJS package](https://npmjs.org/package/phantomjs) like so:\n\n```javascript\nphantom.create(callback,{phantomPath:require('phantomjs').path})\n```\n\n### Working with the API\n\nOnce you have the phantom instance you can use it much as you would the real PhantomJS, node-phantom tries to mimic the api.\n\nAn exception is that since this is a wrapper that does network communication to control PhantomJS, _all_ methods are asynchronous and\nwith a callback even when the PhantomJS version is synchronous.\n\nAnother notable exception is the page.evaluate method (and page.evaluateAsync method) that since PhantomJS 1.6 has a provision for extra arguments\nto be passed into the evaluated function. In the node-phantom world these arguments are placed _after_ the callback. So the\norder is evaluatee, callback, optional arguments. In code it looks like :\n\n```javascript\npage.evaluate(function(s){\n\treturn document.querySelector(s).innerText;\n},function(err,title){\n\tconsole.log(title);\n},'title');\n```\n\n\nYou can also have a look at the test folder to see some examples of using the API.\n\nOther\n-----\nMade by Alex Scheel Meyer. Released to the public domain.\n\n","engines":{"node":"*"},"scripts":{"test":"mocha"},"_npmUser":{"name":"alexscheelmeyer","email":"alexscheelmeyer@gmail.com"},"homepage":"https://github.com/alexscheelmeyer/node-phantom","repository":{"url":"git://github.com/alexscheelmeyer/node-phantom.git","type":"git"},"_npmVersion":"1.2.21","description":"bridge between node.js and PhantomJS","maintainers":[{"name":"alexscheelmeyer","email":"alexscheelmeyer@gmail.com"}],"dependencies":{"socket.io":">=0.9.6"},"readmeFilename":"README.md","devDependencies":{"mocha":"*","pngjs":"0.4.0"},"optionalDependencies":{},"_id":"node-phantom@0.2.5","version":"0.2.5"}