Check if a URL is reachable
Project description
Reachable checks if a URL exists and is reachable.
Features
- Use
HEAD
request instead ofGET
to save some bandwidth - Follow redirects
- Handle local redirects (without full URL in
location
header) - Record all the URLs of the redirection chain
- Check if redirected URL match the TLD of source URL
- Detect Cloudflare protection
- Avoid basic bot detectors
- Use randome Chrome user agent
- Wait between consecutive requests to the same host
- Include
Host
header
- Use of HTTP/2
Installation
You can install it with pip :
pip install reachable
Or clone this repository and simply run :
cd reachable/
pip install -e .
Usage
Simple URL
from reachable import is_reachable
result = is_reachable("https://google.com")
The output will look like this:
{
"original_url": "https://google.com",
"final_url": "https://www.google.com/",
"response": null,
"status_code": 200,
"success": true,
"error_name": null,
"cloudflare_protection": false,
"redirect": {
"chain": ["https://www.google.com/"],
"final_url": "https://www.google.com/",
"tld_match": true
}
}
Multiple URLs
from reachable import is_reachable
result = is_reachable(["https://google.com", "http://bing.com"])
The output will look like this:
[
{
"original_url": "https://google.com",
"final_url": "https://www.google.com/",
"response": null,
"status_code": 200,
"success": true,
"error_name": null,
"cloudflare_protection": false,
"redirect": {
"chain": ["https://www.google.com/"],
"final_url": "https://www.google.com/",
"tld_match": true
}
},
{
"original_url": "http://bing.com",
"final_url": "https://www.bing.com/?toWww=1&redig=16A78C94",
"response": null,
"status_code": 200,
"success": true,
"error_name": null,
"cloudflare_protection": false,
"redirect": {
"chain": ["https://www.bing.com:443/?toWww=1&redig=16A78C94"],
"final_url": "https://www.bing.com/?toWww=1&redig=16A78C94",
"tld_match": true
}
}
]
Async
import asyncio
from reachable import is_reachable_async
result = asyncio.run(is_reachable_async("https://google.com"))
or
import asyncio
from reachable import is_reachable_async
urls = ["https://google.com", "https://bing.com"]
try:
loop = asyncio.get_running_loop()
except RuntimeError:
# No loop already exists so we crete one
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
result = loop.run_until_complete(asyncio.gather(*[is_reachable_async(url) for url in urls]))
finally:
loop.close()
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
reachable-0.5.7.tar.gz
(10.6 kB
view details)
Built Distribution
reachable-0.5.7-py3-none-any.whl
(11.1 kB
view details)
File details
Details for the file reachable-0.5.7.tar.gz
.
File metadata
- Download URL: reachable-0.5.7.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d8c7b5694bcdd495fd59ab47416dab13704e52c2d4164e1a181b6814c838ea7 |
|
MD5 | 87e660837790940cd7868e0dbfa9841e |
|
BLAKE2b-256 | 910e50f5fe93d43372c8600d1861c0319d29eb5333a841aaafb05daac7151b70 |
Provenance
The following attestation bundles were made for reachable-0.5.7.tar.gz
:
Publisher:
publish.yml
on AlexMili/Reachable
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
reachable-0.5.7.tar.gz
- Subject digest:
9d8c7b5694bcdd495fd59ab47416dab13704e52c2d4164e1a181b6814c838ea7
- Sigstore transparency entry: 146814810
- Sigstore integration time:
- Predicate type:
File details
Details for the file reachable-0.5.7-py3-none-any.whl
.
File metadata
- Download URL: reachable-0.5.7-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7fd922d2214753f7dd3aea50557a3ba58cff45221bb0527853d07573579603d |
|
MD5 | 2df513e93b7b7411efe3f07ec454821b |
|
BLAKE2b-256 | 62c249651b4c611e010290731b6594505959a3879450bd1054139491a3be2565 |
Provenance
The following attestation bundles were made for reachable-0.5.7-py3-none-any.whl
:
Publisher:
publish.yml
on AlexMili/Reachable
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
reachable-0.5.7-py3-none-any.whl
- Subject digest:
e7fd922d2214753f7dd3aea50557a3ba58cff45221bb0527853d07573579603d
- Sigstore transparency entry: 146814817
- Sigstore integration time:
- Predicate type: