Last active
March 21, 2017 09:37
-
-
Save vignesh-m/85db3c64231511f564812b6020cacb98 to your computer and use it in GitHub Desktop.
networks lab wget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
def stats(url): | |
os.system('wget ' + url + ' -o logfile') | |
s = open('logfile', 'r').read() | |
def speed(s): | |
a = re.findall('\(.*/s\)', s) | |
def mb2kb(s): | |
if s[-4] == 'K': | |
return float(s[:-5]) | |
else: | |
return 1024 * float(s[:-5]) | |
return mb2kb(a[0][1:-1]) | |
def time(s): | |
a = re.findall('=.*s', s) | |
return float(a[0][1:-1]) | |
return speed(s), time(s) | |
print(stats('localhost:8000/512kb')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment