Thursday, December 26, 2024
Google search engine
HomeLanguagesApplication for Internet speed test using pyspeedtest in Python

Application for Internet speed test using pyspeedtest in Python

While troubleshooting with Internet speed. We need to first check internet bandwidth speed. So, pyspeedtest module test network bandwidth using Speedtest.net servers. So, before starting we need to install pyspeedtest into your system. Run these code to your command line

pip install pyspeedtest

Approach:

  • Import pyspeedtest
  • Create object for SpeedTest()
  • Check ping with ping()
  • Check Download speed with download()
  • Check Upload speed with upload()

Below is the implementation.

Python3




import pyspeedtest
 
 
test = pyspeedtest.SpeedTest("www.youtube.com")
 
test.ping()
test.download()
test.upload()


Output:

253.4427046775818
16461.88637373227
19425388.307319913

Speed Test Application with Tkinter: This Script implements the above Implementation into a GUI.

Python3




import pyspeedtest
from tkinter import *
 
 
def Speed_test():
    t = pyspeedtest.SpeedTest(e1.get())
    myping.set(t.ping())
    down.set(t.download())
 
 
master = Tk()
myping = StringVar()
down = StringVar()
 
Label(master, text="Website URL").grid(row=0, sticky=W)
Label(master, text="Ping Result:").grid(row=3, sticky=W)
Label(master, text="Download Result:").grid(row=4, sticky=W)
 
result = Label(master, text="", textvariable=myping,
               ).grid(row=3, column=1, sticky=W)
 
result2 = Label(master, text="", textvariable=down,
                ).grid(row=4, column=1, sticky=W)
 
 
e1 = Entry(master)
e1.grid(row=0, column=1)
b = Button(master, text="Check", command=Speed_test)
b.grid(row=0, column=2, columnspan=2, rowspan=2, padx=5, pady=5)
 
mainloop()


Output:

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments