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("www.youtube.com")

test.ping()
test.download()
test.upload()

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

Gagan

Hi, there I'm founder of ComputerScienceHub(Started this to bring useful Computer Science information just at one place). Personally I've been doing JavaScript, Python development since 2015(Been long) - Worked upon couple of Web Development Projects, Did some Data Science stuff using Python. Nowadays primarily I work as Freelance JavaScript Developer(Web Developer) and on side-by-side managing team of Computer Science specialists at ComputerScienceHub.io

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts