This commit is contained in:
admin 2024-01-11 22:12:52 +01:00
commit 7322536cf7

View file

@ -0,0 +1,58 @@
import requests
from ping3 import ping
def check_aara_websites():
websites = [
"https://search.spitfirebrowser.com/",
"https://araa.extravi.dev/",
"https://tailsx.com/"
]
results = []
for website in websites:
try:
# Measure loading time
response = requests.get(website, timeout=1)
loading_time = response.elapsed.total_seconds()
# Measure ping
ping_result = ping(website.split("//")[1].split("/")[0], timeout=1)
if ping_result is None:
# Set ping to 120ms if the website loads but doesn't respond to ping
ping_result = 0.12
results.append({
'website': website,
'loading_time': loading_time,
'ping': ping_result
})
# Print ping and loading time for each website
print(f"{website}: Ping = {ping_result} seconds, Loading Time = {loading_time} seconds")
except requests.Timeout:
# Skip the website if it doesn't respond to ping within 2 seconds
print(f"{website}: Timeout, skipping...")
except Exception as e:
# Handle other exceptions (e.g., website unreachable)
print(f"Error checking {website}: {e}")
# Exclude websites that neither load nor respond to ping
results = [result for result in results if 'ping' in result]
# Sort results based on loading time and ping (lower is better)
sorted_results = sorted(results, key=lambda x: (x['loading_time'], x['ping']))
# Return the best available website
best_website = sorted_results[0]['website'] if sorted_results else None
return best_website
if __name__ == "__main__":
best_aara_website = check_aara_websites()
if best_aara_website:
print(f"\nThe best Aara website is: {best_aara_website}")
else:
print("\nNo suitable Aara website found.")