Skip to main content

Clean Links

Release Build status codecov Commit activity License

Decide whether two links point at the same resource — so you can de-duplicate and count links shared across feeds (a Nuzzel-style use case). Shorteners hide the destination and per-share tracking parameters mean the final URLs rarely match as strings; clean-links follows the redirects, strips the cruft, and compares what's left.

Using an AI coding agent? See llms.txt — an LLM-oriented reference covering the full API, the persistent-cache recipe, and the behavioral contracts (caching, TTLs, rate limits, error handling) that function signatures don't reveal.

Install with:

pip install clean_links

Are two shortened, tracking-tagged links the same article?

>>> from clean_links import are_equivalent_sync
>>> are_equivalent_sync(
...     "https://bit.ly/some-short-link",
...     "https://trib.al/another-one",
... )
True

Or count how many links in a batch point at the same thing:

>>> from clean_links import group_sync
>>> groups = group_sync([
...     "https://bit.ly/some-short-link",
...     "https://trib.al/another-one",
...     "https://example.com/unrelated",
... ])
>>> {key: len(members) for key, members in groups.items()}
{'https://www.bloomberg.com/news/articles/...': 2, 'https://example.com/unrelated': 1}

These calls make live network requests to follow the redirects. The library is async-first — drop the _sync suffix for the coroutine API — and an Engine with a SqliteStore resolves each link once and reuses it across runs.

See the documentation here.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clean_links-0.2.2.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clean_links-0.2.2-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

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