Skip to content

Commit d28c5ff

Browse files
author
alanhasn
committed
sixth
1 parent 0c0f26e commit d28c5ff

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Domain url.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import socket
2+
3+
def get_domain_ip():
4+
"""Get the IP address of a given domain."""
5+
try:
6+
url_name = input('Enter the Domain URL(e,g google.com): ').strip()
7+
if not url_name:
8+
print("Error: Domain URL cannot be empty.")
9+
return
10+
11+
ip = socket.gethostbyname(url_name)
12+
print(f"The IP address of {url_name} is: {ip}")
13+
except socket.gaierror:
14+
print("Error: Unable to resolve the domain. Please check the URL.")
15+
except Exception as e:
16+
print(f"An unexpected error occurred: {e}")
17+
18+
if __name__ == "__main__":
19+
get_domain_ip()

0 commit comments

Comments
 (0)