Socket
Socket
Sign inDemoInstall

isbot

Package Overview
Dependencies
0
Maintainers
1
Versions
126
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    isbot

detects bots/crawlers/spiders via the user agent.


Version published
Weekly downloads
515K
increased by0.27%
Maintainers
1
Install size
408 kB
Created
Weekly downloads
 

Package description

What is isbot?

The 'isbot' npm package is a lightweight utility for detecting bots, crawlers, and spiders based on the user agent string. It helps developers identify non-human traffic to their websites or applications.

What are isbot's main functionalities?

Basic Bot Detection

This feature allows you to check if a given user agent string belongs to a bot. The function returns true if the user agent is identified as a bot, otherwise false.

const isBot = require('isbot');

const userAgent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
console.log(isBot(userAgent)); // true

Custom Bot Patterns

You can extend the default bot detection patterns with custom patterns. This is useful if you have specific bots that are not covered by the default list.

const isBot = require('isbot');

isBot.extend(['my-custom-bot']);
const userAgent = 'my-custom-bot';
console.log(isBot(userAgent)); // true

Bot Detection in HTTP Requests

This feature demonstrates how to use 'isbot' to detect bots in incoming HTTP requests. Depending on whether the user agent is a bot, the server responds with a different message.

const isBot = require('isbot');
const http = require('http');

http.createServer((req, res) => {
  if (isBot(req.headers['user-agent'])) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello, bot!');
  } else {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello, human!');
  }
}).listen(3000);

Other packages similar to isbot

Readme

Source

isbot

Build Status

install

npm install isbot --save

usage

isBot(req.headers['user-agent'])

isBot("Googlebot/2.1 (+http://www.google.com/bot.html)") // Googlebot

isBot("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36") // false

Keywords

FAQs

Last updated on 17 Sep 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc