Internet Speed Test with Python
Skills:
AI Pair Programming80%
Key Takeaways
The video demonstrates how to create a simple internet speed test using Python with the speedtest-cli library, allowing users to measure their download and upload speeds as well as ping times.
Full Transcript
[Music] what is going on guys welcome back in today's video we're going to do a simple internet speed test in python so let us get right into it all right so this is going to be quite simple it's not going to be a complicated project but we're going to need a library for this so we're going to open up cmd and we're going to do pip install speed test cli which is for command line which stands for command line uh now we're going to use this library because we need a speed test provider we're not just going to do some random stuff and download something we're going to use a professional speed test provider but we're going to access this provider using this library via python so we're going to install that in my case i already have that installed um this is what we're going to need however when we import it in python we're not going to import speedtest.cli or cli we're going to say import speed test by the way let me just scale up the font size because for the video you always want a larger font size there you go from 22 to 28 they go and let me also reposition my camera will real quick here there you go all right so we're going to use the speed test module and in order to perform a speed test we don't need to do a lot we just need to um create a speed test object so we're going to call this test equals speed test dot speed test like that and now we have this speed test object and we can do a download test we can do an upload test we can do uh we can evaluate the ping and so on uh but first of all we want to find some servers and want to find the best server so what we're going to do first we're going to say test dot get servers get underscore service this is going to get a list of servers so let me write that as a comment here get list of servers that are available for speed tests so once we have that we're going to choose the best server there is so we're going to say best equals test dot get best server there you go and we can also let me just add a comment here as well uh or choose best server by the way we're also going to print some messages here so we're going to say print uh loading server list for example and then print choosing best server and once we have found the server we're going to say print and we're going to use an string found and here now we can also include information about the server so before we write that string let's just go ahead and print best so you're going to see what we get as a result here i'm going to run this and you're going to see that this is a an object it has a lot of information inside of it uh first of all we have a problem doesn't have speed test oh yeah t here is lowercase come on lowercase t loading server list choosing best server and once it's done we're going to get i think it's a dictionary or adjacent object whatever it is which is actually the same thing uh but we can then access the individual fields so in this case it found the best server it has a url which is this one then it has coordinates and it has a location name vienna in this case country austria since i'm located in austria and a bunch of different other uh parameters so what we can do is we can go ahead and say okay once we found the best server we're going to print f string found and then we're going to say best and what we want to put in here is the host so the host is this one here in this case it's going to change every time we run the script probably so found host located in and then we can say oh it's not a string located in and now we can go and say best country there you go so this is just a setup now we can go to the actual speed test now in order to do a speed test we just need to run two commands uh the first one is going to be download and the second one is going to be upload so we're going to say okay print performing download test and then we're going to just say download result equals test dot download there you go now we can copy that and we can change downloads to upload so we have performing upload test upload result test upload and once we have that we can also get the ping result so we can say ping result equals test dot results dot ping so that's actually i think all we need to do now i'm going to print that and you're going to see why we have to format it a little bit more so i'm going to just print the download result i'm going to print the upload result upload result and the ping results there you go so if i run this now you can see again it's choosing the best server then we're going to see okay chose that host in that country uh and then we're going to do the test and then you're going to see the download speed and the upload speed speed but the problem is and i can tell you that right away we're going to get bits per second so bit per second is a very large number because usually you measure uh the download speed and the upload speed uh speed in m bit per second not in bit per second so now it's performing the tests and we should be done any second and then we should get the results take some time there you go so this is the bit per second this is also bit per second upload speed and this is the ping now this is in milliseconds so what we need to do now is we need to do some um some formatting and we can do that by just using an f string here and we can say okay download speed and then in those curly brackets we can say download result and now in order to get m bit from bit we need to divide by 1024 two times so uh what we need to do is we need to say divided by 1024 now if you want to have kilo bits um so k bit then this is enough and if you want to have um if you want to have mbit you just do it one more time like that and what's also important is that we format the floating point precision so we can just say uh colon.2f to just focus on two decimal places uh and that should actually be it all right so we can copy that uh we don't need that for the ping result though let's let's just see i'm going to replace download by upload upload result there you go and here we're just going to say ping and we're going to remove all of this here and we're going to add ms in the end and here we're going to add m bits per second m bit per second there you go so that should be it let's run this and then we should be done so again we're choosing the server list now while this is loading let's again talk about what we did we got all the servers we got the best server we chose it we printed the host we printed the country this is of course all optional you don't need to do it and once we had that we just called the download function the upload function we saved the results the ping is also saved in the results and then we just format it in a way that we get the m bits per second because usually this this thing here is just bits per second and you you're not really interested in those uh large numbers formatted as bits as you can see here download speed speed is 66.98 ambit per second upload speed 15.05 and the ping is the download result okay i'm not going to run this again but here we would have to say ping result obviously then we would get the ping off around 20 milliseconds so that's it for today's video hope you enjoyed it hope you'll learn something if so let me know by hitting the like button leaving a comment in the comment section down below and of course don't forget to subscribe to this channel and hit the notification bell to not miss a single future video for free other than that thank you very much for watching see you next video and bye [Music] you
Original Description
Today we learn how to make a simple Internet speed test in Python.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
💻 The Algorithm Bible Book: https://www.neuralnine.com/books/
🐍 The Python Bible Book: https://www.neuralnine.com/books/
👕 Programming Merch: https://www.neuralnine.com/shop
🌐 Social Media & Contact 🌐
📱 Website: https://www.neuralnine.com/
📷 Instagram: https://www.instagram.com/neuralnine
🐦 Twitter: https://twitter.com/neuralnine
🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/
📁 GitHub: https://github.com/NeuralNine
🎙 Discord: https://discord.gg/JU4xr8U3dm
🎵 Outro Music From: https://www.bensound.com/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from NeuralNine · NeuralNine · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Visualizing Stock Data With Candlestick Charts in Python
NeuralNine
Python Beginner Tutorial #1 - Installation and First Program
NeuralNine
Python Beginner Tutorial #2 - Variables and Data Types
NeuralNine
Python Beginner Tutorial #3 - Operators and User Input
NeuralNine
Python Beginner Tutorial #4 - If Statements and Conditions
NeuralNine
Python Beginner Tutorial #5 - Loops
NeuralNine
Python Beginner Tutorial #6 - Sequences and Collections
NeuralNine
Python Beginner Tutorial #7 - Functions
NeuralNine
Python Beginner Tutorial #8 - Exception Handling
NeuralNine
Python Beginner Tutorial #9 - File Operations
NeuralNine
Python Beginner Tutorial #10 - String Functions
NeuralNine
Python Intermediate Tutorial #1 - Classes and Objects
NeuralNine
Python Intermediate Tutorial #2 - Inheritance
NeuralNine
Python Intermediate Tutorial #3 - Multithreading
NeuralNine
Python Intermediate Tutorial #4 - Synchronizing Threads
NeuralNine
Python Intermediate Tutorial #5 - Events and Daemon Threads
NeuralNine
Python Intermediate Tutorial #6 - Queues
NeuralNine
Python Intermediate Tutorial #7 - Sockets and Network Programming
NeuralNine
Python Intermediate Tutorial #8 - Database Programming
NeuralNine
Python Intermediate Tutorial #9 - Recursion
NeuralNine
Python Intermediate Tutorial #10 - XML Processing
NeuralNine
Python Intermediate Tutorial #11 - Logging
NeuralNine
Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
NeuralNine
Python Data Science Tutorial #2 - NumPy Arrays
NeuralNine
Python Data Science Tutorial #3 - Numpy Functions
NeuralNine
Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
NeuralNine
Python Data Science Tutorial #5 - Subplots and Multiple Windows
NeuralNine
Python Data Science Tutorial #6 - Matplotlib Styling
NeuralNine
Python Data Science Tutorial #7 - Bar Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #8 - Pie Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
NeuralNine
Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
NeuralNine
Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
NeuralNine
Python Data Science Tutorial #12 - Pandas Series
NeuralNine
Python Data Science Tutorial #13 - Pandas Data Frames
NeuralNine
Python Data Science Tutorial #14 - Pandas Statistics
NeuralNine
Python Data Science Tutorial #15 - Pandas Sorting and Functions
NeuralNine
Python Data Science Tutorial #16 - Pandas Merging Data Frames
NeuralNine
Python Data Science Tutorial #17 - Pandas Queries
NeuralNine
Python Machine Learning Tutorial #1 - What is Machine Learning?
NeuralNine
Python Machine Learning Tutorial #2 - Linear Regression
NeuralNine
Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
NeuralNine
Python Machine Learning #4 - Support Vector Machines
NeuralNine
Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
NeuralNine
Python Machine Learning Tutorial #6 - K-Means Clustering
NeuralNine
Python Machine Learning Tutorial #7 - Neural Networks
NeuralNine
Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
NeuralNine
Generating Poetic Texts with Recurrent Neural Networks in Python
NeuralNine
Stock Portfolio Visualization with Matplotlib in Python
NeuralNine
Analyzing Coronavirus with Python (COVID-19)
NeuralNine
Making Text Images Readable Again with Python and OpenCV
NeuralNine
Neural Networks Simply Explained (Theory)
NeuralNine
Motion Filtering with OpenCV in Python
NeuralNine
Top 5 Programming Languages To Learn in 2020
NeuralNine
Simple TCP Chat Room in Python
NeuralNine
Image Classification with Neural Networks in Python
NeuralNine
Edge Detection with OpenCV in Python
NeuralNine
S&P 500 Web Scraping with Python
NeuralNine
Simple Sentiment Text Analysis in Python
NeuralNine
Introduction - Algorithms & Data Structures #1
NeuralNine
More on: AI Pair Programming
View skill →Related Reads
📰
📰
📰
📰
AI CLI Tools Are Eating Each Other's Lunch
Dev.to · Tracepilot
Loop Engineering: The Skill That Just Made Your AI Workflow Obsolete
Medium · Machine Learning
We built a real-time Pokémon TCG AR overlay for live streams and open-sourced everything
Medium · Deep Learning
I tested the new Claude Desktop on Linux - here's how it compares to rival apps
ZDNet
🎓
Tutor Explanation
DeepCamp AI