node package manager

koa-detect-crawler

koa-detect-crawler

Handle http request from crawler (Something like Googlebot)

Example

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));

API

crawler()

crawler.block(name, status)

crawler.handle(GeneratorFunction)

crawler.handle(name, GeneratorFunction)

Example

app.use(crawler.handle('Google', function * () {
  this.body = 'Hello Googlebot ~';
}));

License

The MIT License