Skip to content

Instantly share code, notes, and snippets.

@vwillcox
Last active April 26, 2020 19:49
Show Gist options
  • Save vwillcox/b0351a817e8562ed74f8425ae5b18be0 to your computer and use it in GitHub Desktop.
Save vwillcox/b0351a817e8562ed74f8425ae5b18be0 to your computer and use it in GitHub Desktop.
Quick Python3 wrapper around the official Ookla Speedtest CLI
import subprocess
import json
stdoutdata = subprocess.getoutput("speedtest -f json")
#print(stdoutdata.split()[0])
results = json.loads(stdoutdata)
for key in results:
download = results["download"]["bandwidth"]
upload = results["upload"]["bandwidth"]
isp = results["isp"]
down = str(round(download / 125000, 2))
up = str(round(upload / 125000, 2))
print("Download: "+ down + "Mbps")
print("Upload: " + up + "Mbps")
print("Internet Provider: " + isp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment