Host Live Checker
import requests
import concurrent.futures
import csv
def check_host(host, login, password):
url = f'http://{host}/'
try:
response = requests.head(url, timeout=2)
if response.status_code == 200:
with open('ips.txt', 'a') as result_file:
result_file.write(f'{host}|{login}|{password}\n')
print(f'{host} is still live')
except requests.exceptions.RequestException as e:
print(f'Error checking {host}: {e}')
with open('data.txt', 'r') as f:
reader = csv.reader(f, delimiter='|')
hosts = [(row[0], row[1], '|'.join(row[2:])) for row in reader]
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
futures = [executor.submit(check_host, *host) for host in hosts]
for future in concurrent.futures.as_completed(futures):
future.result()