Doing Internet Speed Test Using Python

Python is a quite simple and powerful programming language in the sense that it can be applied to so many areas like Scientific Computing, Natural Language Processing but one specific area of application of Python which I found quite fascinating is => Using it for Syntax Validations.

Let’s see what steps need to be followed for getting internet speed using Python Programming Language.

  1. Install pyspeedtest package using python3 -m pip install pyspeedtest statement on command line/terminal
  2. Import pyspeedtest package into code using import pyspeedtest statement
  3. Call SpeedTest(URL) Function from pyspeedtest package using pyspeedtest.SpeedTest(URL)
  4. SpeedTest(URL) Function will return an object containing information about ping, download/upload speed
  5. Call ping(), download(), upload() on object retuned by SpeedTest(URL) function call

Let’s put together all these 5 steps as Python Code for testing out Internet Connection Speed.

import pyspeedtest 
test = pyspeedtest.SpeedTest("")

The above code will print out =>

Ping Speed is =>  105.03512620925903
Downloaded Speed is =>  172.1089271827
Upload Speed is => 17.899919192

If your interested then you can check out source code of PySpeedTest Package on Github – PySpeedTest Python Package Github

Leave a Comment