diff --git a/README.md b/README.md index a897115..233e12e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ # BDIX Tester +[![Version](https://img.shields.io/badge/version-1.0.1-blue.svg)](https://github.com/rionislam/BDIX-Tester/releases/tag/v1.0.1) + Check the available BDIX Ftp servers for you easily ## Use @@ -22,3 +24,5 @@ Check the available BDIX Ftp servers for you easily ``` - Just wait and you will see the avaible servers for you. + +- Press **CTRL**+**C** to stop the scanning diff --git a/test.py b/test.py index f762150..1b86304 100644 --- a/test.py +++ b/test.py @@ -3,18 +3,27 @@ file = open("targets.json") targets = json.load(file) -length = len(targets["hosts"]) -for i in range(0, length): - host = targets["hosts"][i] - try: - response = requests.get(host, timeout=1) - status = response.status_code - except: - status = 'error' +file.close() + +try: + for host in targets.get("hosts", []): + try: + response = requests.get(host, timeout=1) + response.raise_for_status() + status = response.status_code + except requests.exceptions.RequestException as e: + status = 'error' + + continue + + if status == 200: + time = response.elapsed.total_seconds() + size = len(response.content) + speed = (size * 8) / (time * 1000000) + print(f"Host: {host} AND Speed: {speed:.2f} Mbps\n") + response.close() - if status == 200: - time = response.elapsed.total_seconds()/1000 - size = (((len(response.text))/1000000)/8)/8 - speed = size/time - print (f"Host: {host} AND Speed: {format(speed, '.2f') }MBps\n") + +except KeyboardInterrupt: + print("\nScript terminated by user (Ctrl+C).")