Clean URLs by removing tracking parameters and decoding redirects
Project description
Sanitizr - URL Cleaner
A powerful and modular URL cleaning library and CLI tool that removes tracking parameters and decodes redirects.
Features
- 🧹 Clean URLs by removing tracking parameters
- 🔄 Decode redirect URLs (Google, Facebook, etc.)
- ⚙️ Customizable parameter whitelisting/blacklisting
- 🧰 Supports both Python API and CLI usage
- 📋 Process URLs from clipboard, files, or standard input
- 🔧 Configurable via JSON or YAML files
Installation
You can install Sanitizr from PyPI:
pip install sanitizr
For development setup:
pip install -e ".[dev]"
Quick Start
Command Line
# Clean a single URL
sanitizr -u "https://example.com?id=123&utm_source=newsletter"
# Clean URLs from a file
sanitizr -i urls.txt -o cleaned_urls.txt
# Clean URLs from stdin
cat urls.txt | sanitizr > cleaned_urls.txt
# Use verbose output to see the changes
sanitizr -u "https://example.com?id=123&utm_source=newsletter" -v
Python API
from sanitizr.sanitizr import URLCleaner
cleaner = URLCleaner()
clean_url = cleaner.clean_url("https://example.com?id=123&utm_source=newsletter")
print(clean_url) # https://example.com?id=123
Configuration
Sanitizr can be configured via JSON or YAML files:
# config.yaml
tracking_params:
- custom_tracker
- another_tracker
redirect_params:
custom.com:
- redirect
- goto
whitelist_params:
- keep_this_param
blacklist_params:
- remove_this_param
Use the configuration with the --config option:
sanitizr -u "https://example.com?id=123&custom_tracker=abc" --config config.yaml
License
Sanitizr is licensed under the GNU General Public License v3.0 or later - see the LICENSE file for details.
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 sanitizr-1.0.1.tar.gz.
File metadata
- Download URL: sanitizr-1.0.1.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e115e7894d510a307e5d29ec5d0eba01bc3e113e93579cf8de91108c632a685
|
|
| MD5 |
23f401f4b395eb306bdcef2b5addeb6e
|
|
| BLAKE2b-256 |
273c716b5ba45265bc7db1ac5abe66d9361d6c36209f47c50dc32f519b3bdfbf
|
File details
Details for the file sanitizr-1.0.1-py3-none-any.whl.
File metadata
- Download URL: sanitizr-1.0.1-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daf85ae7f7b1f02d98dadd758ae8c0f1c88c2a3c3d4a77500ffaa2b86e9f6137
|
|
| MD5 |
273d23fa52ac4fd4a1bbdfacb4293749
|
|
| BLAKE2b-256 |
e70493767b2e13f7ed09fef4f99bd458de937bcb52aa733688d9f528ada63db5
|