Remove tracking parameters from URLs
Project description
philiprehberger-url-clean
Remove tracking parameters from URLs.
Installation
pip install philiprehberger-url-clean
Usage
from philiprehberger_url_clean import clean, remove_params, normalize
# Remove tracking params (utm_*, fbclid, gclid, etc.)
clean("https://example.com/page?utm_source=twitter&id=123")
# "https://example.com/page?id=123"
# Remove specific params
remove_params("https://example.com?a=1&b=2&c=3", ["b", "c"])
# "https://example.com?a=1"
# Normalize URL
normalize("HTTPS://Example.COM/path/../page?b=2&a=1")
# "https://example.com/page?a=1&b=2"
# Batch processing
clean_many(["https://example.com?utm_source=x", ...])
# Get the list of stripped params alongside the cleaned URL
from philiprehberger_url_clean import clean_url, register_tracking_param
cleaned, removed = clean_url("https://example.com?utm_source=x&id=1")
# cleaned = "https://example.com?id=1"
# removed = ["utm_source"]
# Add a custom tracking param at runtime
register_tracking_param("internal_ref")
clean("https://example.com?internal_ref=abc&id=1")
# "https://example.com?id=1"
API
| Function / Class | Description |
|---|---|
clean(url, extra_params=None) |
Remove known tracking parameters |
clean_url(url, extra_params=None) |
Returns (cleaned_url, removed_params) tuple |
remove_params(url, params) |
Remove specific parameters |
normalize(url) |
Lowercase host, sort params, resolve path |
clean_many(urls, extra_params=None) |
Batch clean |
register_tracking_param(name) |
Add a parameter to the global tracking set |
unregister_tracking_param(name) |
Remove a parameter from the global tracking set |
Development
pip install -e .
python -m pytest tests/ -v
Support
If you find this project useful:
License
Project details
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 philiprehberger_url_clean-0.2.0.tar.gz.
File metadata
- Download URL: philiprehberger_url_clean-0.2.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80a2e816c39f5e2eded5fa8cc503ccfb3e1d058e32e9122858e5e43844abb158
|
|
| MD5 |
34377d1b57c7d7d24c018a3b6105bebd
|
|
| BLAKE2b-256 |
96b48cfdb2aa9ef42aad61af36cc71e04d61e002e6ab8f96543b8d37d3586076
|
File details
Details for the file philiprehberger_url_clean-0.2.0-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_url_clean-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d3981c4731d48cea89a1c587f4c1955641ceb5c28c664c2493944203551a993
|
|
| MD5 |
317baa4bd36fa214a2e52c84e57b6182
|
|
| BLAKE2b-256 |
49123c7d5f83e0624344c655f4430491e9118c2cc653dc02265f11e53d70815a
|