Added libs

This commit is contained in:
Lucas
2026-01-25 13:55:46 +10:00
parent 575c682afc
commit f70af3c4ea
229 changed files with 26983 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import requests
from requests.exceptions import RequestException, Timeout
def check_url(url: str, timeout: int = 10, retries: int = 3, verify_ssl: bool = False) -> bool:
"""
Check if a given URL is reachable.
Args:
url (str): The URL to check.
timeout (int): Timeout for each request in seconds.
retries (int): Number of retry attempts before failing.
verify_ssl (bool): Verify SSL.
Returns:
bool: True if the URL is reachable, False otherwise.
"""
for attempt in range(retries):
try:
response = requests.head(url, timeout=timeout, allow_redirects=True, verify=verify_ssl)
if 200 <= response.status_code < 400:
return True
except (RequestException, Timeout):
continue
return False