urlhealth
A Python library to check whether a URL is live, dead, or likely hallucinated. When a URL is dead, it automatically checks the Wayback Machine for an archived snapshot.
Installation
pip install urlhealth
Dependencies
Usage
from urlhealth import inspect, URLStatus
result = inspect("https://example.com")
print(result["url_status"]) # URLStatus.LIVE, .DEAD, .UNKNOWN, or .LIKELY_HALLUCINATED
print(result["status_code"]) # HTTP status code (int or None)
print(result["wayback_url"]) # Wayback Machine archive URL (str or None)
Return value
inspect(url, timeout=10) returns a dict with three keys:
| Key | Type | Description |
|---|---|---|
url_status |
URLStatus |
LIVE (200), DEAD (404 with Wayback snapshot), LIKELY_HALLUCINATED (404 without snapshot), or UNKNOWN (other status / connection error) |
status_code |
int | None |
HTTP status code, or None if the request failed |
wayback_url |
str | None |
Archive URL when status is DEAD, otherwise None |
URLStatus enum
class URLStatus(str, Enum):
LIVE = "LIVE"
DEAD = "DEAD"
UNKNOWN = "UNKNOWN"
LIKELY_HALLUCINATED = "LIKELY_HALLUCINATED"
Since URLStatus is a str enum, you can compare directly with strings:
if result["url_status"] == "LIVE":
print("URL is reachable")
How it works
- Sends an HTTP
HEADrequest to the URL (falls back toGETif the server returns 405, 403, or 501). - If the response is 200, the URL is
LIVE. - If the response is 404, queries the Wayback Machine API:
- Archived snapshot found →
DEAD(withwayback_urlpopulated). - No snapshot →
LIKELY_HALLUCINATED.
- Archived snapshot found →
- Any other status code or connection error →
UNKNOWN.
License
See LICENSE for details.
Metadata
Release files for urlhealth 0.1.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 | |
|---|---|---|---|---|
| urlhealth-0.1.0.tar.gz | 5.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| urlhealth-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / urlhealth-0.1.0.tar.gz
| Download URL | urlhealth-0.1.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
162b3b83806aee09eac348d8290089c19e84f1ea50cc633701d969f46c055246
|
|
BLAKE2b-256 checksum How to use checksums |
832ae4875a2a5e1f011e98f24b3bc238f3a76340b28ffbd780f99164befd175f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Release files / urlhealth-0.1.0-py3-none-any.whl
| Download URL | urlhealth-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8681ea39e4ee462298af6acd29f8bd9a929a4fb6da3b24d40b50be89a500af1b
|
|
BLAKE2b-256 checksum How to use checksums |
8c5a3d5e72ddeef8ed2186bc6c2042d137c654827801dbbcc9023dc9d43fe793
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.2
|
Security for urlhealth 0.1.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.