A wrapper for PhantomJS for simple data fetching


'phantom-fetch' is a wrapper for PhantomJS for simple data fetching from the web.

To install, type

npm install phantom-fetch

or add it to your package.json as a dependency.

require phantom-fetch:

var fetcher = require('phantom-fetch');

Set the polling function that will be run on the site:

function pollingFunction() {
  return document.querySelector('title').innerHTML;

The polling function should return a falsy value while the wanted value is not available.

Set a callback for when the wanted value is returned, or when the timeout is reached:

function callback(err, id, result, exit) {

And initiate the fetcher:

  id: 1,
  url: "",
  pollingFunction: pollingFunction,
  callback: callback

Also, options could be set with:

  verbose: true, //def false
  interval: 500, //def 100
  timeout: 4000 //def 10000

For more examples, see here

If you are having any problems, requests or criticism, don't hesitate to open an issue, here