Python 3 Script to Test the Speed & Check the Loading Speed of Website in Seconds in Terminal
1K views
Jun 3, 2025
Get the full source code of application here: https://codingshiksha.com/python/python-3-script-to-test-the-speed-check-the-loading-speed-of-website-in-seconds-in-terminal/
View Video Transcript
0:00
uh hello guys uh welcome to this video
0:02
so in this video I will show you a
0:04
Python script which will actually test
0:06
out your speed and check the loading
0:09
speed of your website directly in the
0:11
terminal it will tell you how much
0:13
loading time it takes to actually fully
0:16
load your website it is a very useful
0:19
script for search engine optimization
0:22
you will be able to see how much time
0:23
your website is taking so let's suppose
0:25
I'm
0:26
basically written the script here
0:30
so I'm just uh wanted to know the
0:32
loading speed of my website e-commerce
0:35
website which is procodestore.com so I
0:37
put this script in the website in the
0:40
script here and as soon as I load uh run
0:44
the script here by executing pythonapp
0:46
py so it will take some time and then it
0:50
will load the website in the background
0:51
and it will exactly tell me that the
0:54
loading time of the website is round
0:56
about 1.29 29
0:59
seconds i can change the URL here let's
1:02
suppose I say free media tools.com which
1:05
is my toolbased website let's suppose I
1:08
want to know the loading time of this
1:10
website again you will see the loading
1:13
time of website is
1:15
0.072 seconds so you can see the drastic
1:18
difference we can even crossverify as
1:20
well by Google page speed inside so
1:25
there are lots of online tools you can
1:27
actually go to to actually measure
1:32
the loading time of the website this is
1:35
provided by Google so essentially it is
1:38
using this Python script in the
1:39
background to actually analyze it you
1:41
will see it is running the analysis
1:44
and you can see
1:48
again it is doing everything in the
1:50
background and
1:54
uh so I will show you this Python script
1:57
uh which is actually using the free
1:59
open-source packages to measure this
2:01
loading time so I've given the full
2:03
script in the description of the video
2:06
so first of all what we need to do uh in
2:09
order to make this we need to import the
2:12
URL lib module and inside this module we
2:16
have this request class and from this
2:19
you just need to import this URL
2:23
open method after that we just need to
2:27
import the time
2:31
uh class from time module so all these
2:35
two modules are built in inside Python
2:38
you did not have to install it so after
2:40
just import this and here you just
2:44
create a variable where you open the
2:47
website and passing it to this URL open
2:50
function so it will actually open this
2:53
website in the background so it suppose
2:56
I provide here google.com so it will
2:59
simply go to this website in the
3:00
background and
3:01
then after that now to measure the time
3:05
here we will initialize this time
3:07
constructor so it will
3:10
actually send how much time it took and
3:13
it will store it inside this variable
3:16
and now we can
3:18
actually the output here we can read
3:21
this the
3:23
website dot read method so it will
3:27
actually read this data using this
3:29
object it contains this read method and
3:33
after that the close
3:36
time we can make it and just create the
3:40
time here the current time here so we
3:44
will measure the difference here the
3:46
opening time closing time minus opening
3:49
time this will give you the loading time
3:52
so now in the next step we can simply
3:55
print the time taken to open
4:00
website the loading time of website is
4:04
and then we will use the round function
4:08
and here we will take the difference of
4:11
close time minus open time this is
4:14
actually your formula here and then we
4:17
will put round it off and
4:21
uh so this will be coming out in seconds
4:25
so the time interval will be in sec
4:27
seconds here so if I again execute this
4:30
you will see
4:31
that the loading time of website is
4:35
0.025 seconds
4:37
so you can take any website for example
4:40
just you plug the URL and then you can
4:43
directly measure it the loading time
4:45
interval directly in the terminal itself
4:48
you can see 0.638 seconds so every time
4:51
the URL the loading time will be
4:53
different depending upon the website so
4:56
here you can this is a very simple
4:58
script which gives you test the loading
5:01
speed and gives you the loading time of
5:03
the website in seconds so thank you very
5:06
much for watching this video and uh
5:09
please hit that like button subscribe
5:11
the channel as well and also check out
5:14
my website freemediattools.com
5:18
uh which contains thousands of tools
#Search Engine Optimization & Marketing
#Web Services
#Web Stats & Analytics