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:
{
"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:
[
{
"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
}
},
{
"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"))
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
reachable-0.2.0.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for reachable-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce00f08b210caf3fae53f138b0232057e72b98898bede20787770e6dc377d61f |
|
MD5 | 2da3951fc439a4c37378a0ff3e33adfe |
|
BLAKE2b-256 | 771850abb61e5a1dc79c2075a82e5daf8dea35835263b7bc50947d1b9cc9cfb3 |