Skip to content

Commit 8010e96

Browse files
committed
Added script to check website load time
1 parent 7b998cf commit 8010e96

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Time to load website
2+
3+
This script takes a url from the user and returns the time taken to load that website.
4+
5+
## How to use this ?
6+
7+
1. Just type the following on the command prompt:
8+
9+
python time_to_load_website.py
10+
11+
2. It will reuest you to provide a url. Provide the url and hit enter to see the script in action.
12+
13+
## Sample use:
14+
15+
<p align = "center">
16+
<img src="sample.PNG" alt="sample">
17+
</p>
7.42 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from urllib.request import urlopen
2+
import time
3+
4+
#Storing user defined URl
5+
URL = input("Enter the url whose loading time you want to check: ")
6+
7+
#Open the url as entered by the user and checking protocols
8+
if ("https" or "http") in URL:
9+
open_this_url = urlopen(URL)
10+
11+
else:
12+
open_this_url = urlopen("https://" + URL)
13+
14+
#Time stamp before the reading of url starts
15+
start_time = time.time()
16+
17+
#Reading the user defined url
18+
read_the_url = open_this_url.read()
19+
20+
#Time stamp after the reading of the url
21+
end_time = time.time()
22+
23+
#Closing the instance of the urlopen object
24+
open_this_url.close()
25+
26+
print()
27+
print(f"The time taken to load {URL} is {end_time - start_time}")

0 commit comments

Comments
 (0)