Interface: Runner

Runner

A webpage runner blueprint

Methods

getCompanionFiles() → {Array|Promise.<Array>}

The (local) files returned by this method are injected into the webpage before the method received from Runner#getRunnable is evaluated. Any global exposed by the companion files can be accessed by the method returned from Runner#getRunnable.
Source:
Returns:
Has to either return an Array or a Promise resolving to an Array. Return an empty Array if your code does not need companion files.
Type
Array | Promise.<Array>

getRunnable() → {function}

A method to get a function from that is evaluated within the web page and returns a result. The returned function should call back with an result of any serializable kind by calling `window.callPhantom(error, result)`. If your method did not provoke an error, pass null as the first argument. The time out of the returned function is controlled via Runner#timeout. The returned function will be called immediately after page load, any defined Finder and other Runners added before.
Source:
See:
Returns:
A function to be evaluated within the crawled webpage
Type
function

transformResult(result) → {Promise.<*>}

Optional. A method to do post processing on the result returned from calling the result of the method returned from Runner#getRunnable. Will not be called on errors. This method runs in node-space.
Parameters:
Name Type Description
result * The result returned from the page runner
Source:
Returns:
A promise resolving to the post-processed result
Type
Promise.<*>