Python: Test Your Internet Download and Upload Speed Using speedtest-cli

In this tutorial, we will introduce how to know your internet download and upload speed using python speedtest-cli.

Python - Test Your Internet Download and Upload Speed Using speedtest-cli

1.Install speedtest-cli

pip install speedtest-cli

2.Import library

import speedtest

3.List all methods in speedtest

s = speedtest.Speedtest()
import inspect

for method in inspect.getmembers(s, predicate=inspect.ismethod):
    print(method)

Run this code, you may get a list:

download
upload
get_best_server
get_closest_servers
get_servers
set_mini_server
get_config

4.Get internet download speed

print('My download speed is:', s.download())

5.Get internet upload speed

print('My upload speed is:', s.upload())