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.
- Install pyspeedtest package using python3 -m pip install pyspeedtest statement on command line/terminal
- Import pyspeedtest package into code using import pyspeedtest statement
- Call SpeedTest(URL) Function from pyspeedtest package using pyspeedtest.SpeedTest(URL)
- SpeedTest(URL) Function will return an object containing information about ping, download/upload speed
- 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