Skip to main content

🤖 ConfusedAICrawlers

ConfusedAICrawlers is a lightweight Flask extension designed to detect and block AI web crawlers using their User-Agent strings.

It supports a customizable JSON configuration for blacklisting or whitelisting crawlers, integrates seamlessly with flask-limiter for rate limiting, and includes a simple admin route for reloading configurations without restarting your app.

🚀 Features

  • Block known AI crawlers by inspecting the User-Agent header.
  • Whitelist trusted crawlers (e.g., Googlebot).
  • Plug-and-play integration using a Flask Blueprint.
  • Optional /robots.txt route to discourage all crawlers.
  • JSON config file for flexible control.
  • Reload crawler configuration on the fly with an admin route.

📦 Installation

Install via pip: pip install confusedaicrawlers

🛠️ Usage

1. Basic Integration

from flask import Flask
from confusedaicrawlers import FlaskAIBlocker

app = Flask(__name__)
ai_blocker = FlaskAIBlocker()  # Defaults to ai_crawlers.json
ai_blocker.init_app(app)

@app.route('/')
def index():
    return "Hello, human!"

if __name__ == '__main__':
    app.run()

2. With Flask-Limiter

from flask import Flask
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
from confusedaicrawlers import FlaskAIBlocker

app = Flask(__name__)
limiter = Limiter(key_func=get_remote_address)
limiter.init_app(app)

ai_blocker = FlaskAIBlocker(config_path="your_config_path.json")
ai_blocker.init_app(app)

⚙️ Configuration (JSON)

The extension expects a JSON file like this:

{
  "blacklist": {
    "chatgpt": "ChatGPT",
    "openai": "OpenAI"
  },
  "whitelist": {
    "google": "Googlebot",
    "bing": "Bingbot"
  }
}
  • Blacklist: Crawler fragments to block (case-insensitive).
  • Whitelist: Allowed bots (checked first).

🔁 Admin Endpoint

Reload the config file at runtime without restarting the app:

POST /admin/reload-config

Response:

{
  "status": "success",
  "message": "Configuration reloaded"
}

📁 Project Structure

confusedaicrawlers/
├── confusedaicrawlers/
│   ├── __init__.py
│   ├── blocker.py
│   └── ai_crawlers.json
├── tests/
│   └── test_blocker.py
├── README.md
├── pyproject.toml
├── requirements.txt
└── MANIFEST.in

✅ License

This project is licensed under the MIT License.

🤝 Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.

Metadata

Release files for blockaicrawlers 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blockaicrawlers 0.1.0
File Size Uploaded Provenance
blockaicrawlers-0.1.0.tar.gz 4.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for blockaicrawlers 0.1.0
File Interpreter ABI Platform
blockaicrawlers-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / blockaicrawlers-0.1.0.tar.gz

Download URL blockaicrawlers-0.1.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0de1bd59293028be3f9b730ed8757b89e6f0aec884b07b8e2307d6eab804ac42
BLAKE2b-256 checksum
How to use checksums
9619fbfa290a193c59a7159404e83434e0da3e23b954e0b9f3ba752e9613d218
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / blockaicrawlers-0.1.0-py3-none-any.whl

Download URL blockaicrawlers-0.1.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19bf87ce8a6d56349d84c135d4f20e6936483b23553e5d5b71744481794008d6
BLAKE2b-256 checksum
How to use checksums
78e4523633d6e1424dc14056920d939be78cfbf7536557eb6f8c6e9729a48fec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for blockaicrawlers 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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