Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Detect spiders/crawlers/bots by their User-Agent strings.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
.npmignore
.travis.yml
LICENSE.md
README.md
index.js
package.json
regex.js

README.md

funnelweb Build Status

Tries to detect if a request is coming from a machine or a person using a regular expression. Bot and browser User-Agent strings sourced from useragentstring.com.

Installation

$ npm install funnelweb

Usage

Funnelweb just takes a user agent string and returns "true" if it's probably a bot, or "false" otherwise.

var funnelweb = require('funnelweb')

funnelweb('GoogleBot') // true
funnelweb('Google Chrome') // false

If you pass it an HTTP request object, it'll read the User-Agent header and do the same:

var funnelweb = require('funnelweb')
  , http = require('http')

http.createServer(function(req, res) {
  var response = funnelweb(req)

  if (bot) {
    res.end('you are a bot')
  } else {
    res.end('you are not a bot')
  }
}).listen(3000)
Something went wrong with that request. Please try again.