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.7.tar.gz (9.7 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.7-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: is_bot-0.3.7.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for is_bot-0.3.7.tar.gz
Algorithm Hash digest
SHA256 57a83dc85b2d53603a173d7d7e62febfd442f43669792ede8818497ac2d22f7f
MD5 2b2be9262f4a6f564c6579f201e5ddd0
BLAKE2b-256 26596d73ad2e8cdcd79a6b928af73dd28e20054dc5be22f55b59efb59cdeaf1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: is_bot-0.3.7-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for is_bot-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c9086ed8e03993c21e4c5af5851f92e6c06ca6011195814131a7c4048c23e3a4
MD5 6d56bd4e62d42d166c262ddd6ca0ffe4
BLAKE2b-256 11f22155f3b97d01573ed9ededcf44aa23235746a1e0e827c2f444c2b7fef9e5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.7 This release

2 files

0.3.6

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