Skip to content

Commit a8fa94f

Browse files
authored
Add files via upload
1 parent 261af24 commit a8fa94f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import urllib.request
2+
import urllib.error
3+
4+
def URL_CHECK(url):
5+
print('Checking connectivity...')
6+
7+
try:
8+
response = urllib.request.urlopen(url)
9+
print('Connected to ' + url + ' successfully')
10+
print(f'Response code: {response.getcode()}')
11+
except urllib.error.URLError as e:
12+
print(f'Failed to connect to {url}. Reason: {e.reason}')
13+
14+
def main():
15+
user_url = input('Enter a URL (include http:// or https://): ')
16+
17+
# Check if the URL starts with http:// or https://
18+
if not user_url.startswith(('http://', 'https://')):
19+
print("Invalid URL. Please ensure it starts with 'http://' or 'https://'.")
20+
return
21+
22+
URL_CHECK(user_url)
23+
24+
if __name__ == '__main__':
25+
main()

0 commit comments

Comments
 (0)