- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFetch HTTP status code.py
More file actions
Latest commit
16 lines (14 loc) · 696 Bytes
/
Copy pathFetch HTTP status code.py
File metadata and controls
16 lines (14 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
fromurllib.requestimporturlopen
fromurllib.errorimportURLError, HTTPError
importemoji
URL=input("Enter the URL: ")
try:
response=urlopen(URL)
print('Status code : '+str(response.code) +' '+emoji.emojize(':thumbs_up:'))
print('Message : '+'Request succeeded. Request returned message - '+response.reason)
exceptHTTPErrorase:
print('Status : '+str(e.code) +' '+emoji.emojize(':thumbs_down:'))
print('Message : Request failed. Request returned reason - '+e.reason)
exceptURLErrorase:
print('Status :', str(e.reason).split(']')[0].replace('[','') +' '+emoji.emojize(':thumbs_down:'))
print('Message : '+str(e.reason).split(']')[1])