Skip to main content

is-bot

CI Coverage Status PyPI version

Python package to detect bots/crawlers/spiders via user-agent string. This is a port of the isbot JavaScript module.

Requirements

  • Python >= 3.8
  • regex >= 2022.8.17

Installation

pip install is-bot

Usage

Simple usage

from is_bot import Bots

bots = Bots()

ua = 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/104.0.5112.79 Safari/537.36'
assert bots.is_bot(ua)

ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'
assert not bots.is_bot(ua)

Add/remove parsing rules

from is_bot import Bots

bots = Bots()

# Exclude Chrome-Lighthouse from default bot list
ua = 'Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4695.0 Mobile Safari/537.36 Chrome-Lighthouse'
assert bots.is_bot(ua)
bots.exclude(['chrome-lighthouse'])
assert not bots.is_bot(ua)

# Add some browser to default bot list
ua = 'SomeAwesomeBrowser/10.0 (Linux; Android 7.0)'
assert not bots.is_bot(ua)
bots.extend(['SomeAwesomeBrowser'])
assert bots.is_bot(ua)

Get additional parsing information

from is_bot import Bots

bots = Bots()

ua = 'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 SearchRobot/1.0'

# view the respective match for bot user agent rule
print(bots.find(ua))
#> Search

# list all patterns that match the user agent string
print(bots.matches(ua))
#> ['(?<! (ya|yandex))search', '(?<! cu)bot']

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

is_bot-0.3.6.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

is_bot-0.3.6-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file is_bot-0.3.6.tar.gz.

File metadata

  • Download URL: is_bot-0.3.6.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for is_bot-0.3.6.tar.gz
Algorithm Hash digest
SHA256 e99d4b71ef916912c82a1ccb61cf0df55e78a4b98c9a69787a2431e664750af8
MD5 2bb33ba31d1b544289261d9a6f4fc85a
BLAKE2b-256 d10e06f6810d93aa3b1df934c97b521bd0e0c3ad0b98a2dd39fcdf34587099df

See more details on using hashes here.

File details

Details for the file is_bot-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: is_bot-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for is_bot-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 85cf5eeb7c1d94ba9b9ecb5b2e99ba108a685b7f7131b2a4b9b14badbb0eeb05
MD5 1e5063dab91afd377d6143ca7b3b0ac2
BLAKE2b-256 d3ca69c6a56754dc26bea14d1034bcdcb18942142096b0d35d2ff4a7662289bc

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.7

2 files

This release

0.3.6 This release

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page