A fast, cached Python library to detect and block spam URL shortener domains.
Project description
Antispam Link Shorteners 🛡️
A Python library designed to detect and block spam URL shortener domains using a blocklist.
This package provides a reliable way to check if a URL or domain belongs to a known link shortener (such as bit.ly,
t.co, tinyurl.com).
It helps developers protect their platforms from re-linking spam, chain shortening, and potential security risks.
The blocklist is loaded into an in-memory set and cached via lru_cache. Subsequent checks require zero disk I/O
overhead ($O(1)$ Complexity).
📦 Installation
Install the package using pip:
pip install antispam-link-shorteners
🚀 Usage
The library provides simple function: link_shorteners_list.
Use link_shorteners_list() to get the entire cached set of lowercase domains:
from antispam_link_shorteners import link_shorteners_list
banned_shorteners = link_shorteners_list()
print("bit.ly" in banned_shorteners) # True (O(1) lookup)
👥 Credits & Attribution
This library relies on the following open-source resources:
- Data Source: The domain blocklist text file is directly sourced from the PeterDaveHello/url-shorteners.
- Original library: This library is a heavily refactored, optimized, and modernized Python alternative based on the mayakyler/link-shorteners.
⚖️ License
This project uses a multi-license structure to cleanly respect all upstream authors:
- Modified library: Licensed under the MIT License.
- Original library:: Licensed under the MIT License.
- Blocklist Dataset: Distributed under the Creative Commons Attribution-ShareAlike 4.0 International License ( CC-BY-SA-4.0).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file antispam_link_shorteners-0.1.0.tar.gz.
File metadata
- Download URL: antispam_link_shorteners-0.1.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23b44e092af9280a2fdb7132b3bc76ee29ab4b2a1eb19673cf29906f47de776b
|
|
| MD5 |
4a823a54f30ea44a7d98e6fdeee7faab
|
|
| BLAKE2b-256 |
70b80982227056424fa0af5fa41b2aaf9e1a8954b32e4bac01290ade5cca2854
|
File details
Details for the file antispam_link_shorteners-0.1.0-py3-none-any.whl.
File metadata
- Download URL: antispam_link_shorteners-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62c4ad827439ac4386e9d0ebfc009994d141f6c696a53267b9bc472c3af848b9
|
|
| MD5 |
0c4924fcc3d126121f4971b29f450535
|
|
| BLAKE2b-256 |
1f49116e384f20b4df8d6977c310fc13fcd1a3fac6239174e119be4a069158c8
|