koa-detect-crawler

Handle http request from crawler (Something like Googlebot)

Handle http request from crawler (Something like Googlebot)

var crawler = require('koa-detect-crawler');
var app = koa();
 
app.use(crawler());
 
app.use(function *(next) {
  console.log(this.crawler); // crawler name or null 
  yield* next;
});
 
app.use(crawler.block('GoogleImage', 403));
app.use(crawler.handle('Google', function * () {
  this.body = 'Hello Googlebot ~';
}));

The MIT License