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"
Extracting the domain
from philiprehberger_url_clean import domain
domain("https://Example.com/foo?utm=x")
# "example.com"
domain("https://example.com:8080/")
# "example.com"
domain("example.com/path")
# "example.com"
Checking if a URL is clean
from philiprehberger_url_clean import is_clean
is_clean("https://example.com/?id=42")
# True
is_clean("https://example.com/?utm_source=newsletter")
# False
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 |
domain(url) |
Return the lowercased hostname from a URL |
is_clean(url) |
Return True when no tracking params are present |
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
Metadata
Release files for philiprehberger-url-clean 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| philiprehberger_url_clean-0.3.0.tar.gz | 174.7 kB | Without provenance | Details for philiprehberger_url_clean-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| philiprehberger_url_clean-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for philiprehberger_url_clean-0.3.0-py3-none-any.whl |
Total release size: 180.1 kB
Release files / philiprehberger_url_clean-0.3.0.tar.gz
| Download URL | philiprehberger_url_clean-0.3.0.tar.gz |
|---|---|
| Size | 174.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2bace63b20de9901201e9fae513bdef8c761fd75b9279a07699d021939e3cce
|
|
BLAKE2b-256 checksum How to use checksums |
300c011e69b790296efeecbfccb3639a67c802cba31f9a9c12ffecc6bb531858
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / philiprehberger_url_clean-0.3.0-py3-none-any.whl
| Download URL | philiprehberger_url_clean-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad90806a4593614186e95fcad6d64ae0584ecec819c42d7f1927f908dbad2e06
|
|
BLAKE2b-256 checksum How to use checksums |
cc85b21d087cb5ae9c15801419bc5c30fbf257dde2a33b3d815130a36520c96c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for philiprehberger-url-clean 0.3.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.