Skip to content

Instantly share code, notes, and snippets.

@ChandanShakya
Created May 24, 2022 04:21
Show Gist options
  • Save ChandanShakya/d3f65358a1469fc7eef2f83d1ca8ced6 to your computer and use it in GitHub Desktop.
Save ChandanShakya/d3f65358a1469fc7eef2f83d1ca8ced6 to your computer and use it in GitHub Desktop.
Python script to do speedtest using speedtest-cli
from speedtest import Speedtest
st = Speedtest()
# Download speed in Mbps
download = round(st.download() / 10**6, 2)
# Upload speed in Mbps
upload = round(st.upload() / 10**6, 2)
# Ping in ms
ping = round(st.results.ping, 2)
# Server name
server = st.results.server['name']
# Server Location
location = st.results.server['country']
print("Download:", download, "Mbps")
print("Upload:", upload, "Mbps")
print("Ping:", ping, "ms")
print("Server:", server)
print("Location:", location)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment