UNPKG

950 BJavaScriptView Raw
1/**
2 * This is a simple plugin which log on the console the crawled urls
3 *
4 */
5
6function Plugin(crawler) {
7
8 this.name = "Console-Plugin";
9
10}
11
12
13Plugin.prototype.crawl = function(result, $, callback) {
14 console.log(result.statusCode + ',' + result.method + ',' +
15 result.uri + ',' + result.responseTime + ',' + (result.proxy ? result.proxy : "no-proxy") );
16 callback();
17}
18
19Plugin.prototype.error = function(error, result, callback) {
20
21 console.log(error.code + ',ERROR,' +
22 result.uri + ',no-response-time,' + (result.proxy ? result.proxy : "no-proxy"));
23 callback();
24
25};
26
27Plugin.prototype.recrawl = function(error, result, callback) {
28 console.log(error.code + ',RECRAWL(' + result.currentRetries + '),' +
29 result.uri + ',no-response-time,' + (result.proxy ? result.proxy : "no-proxy") + " delay:" + result.retryTimeout);
30 callback();
31
32};
33
34
35module.exports.Plugin = Plugin;