Getting ip address using python
Script to get the ip address from domain name. Here's the code
import socket
# fungsi untuk semak dns
def check_dns(hostname):
try:
# menyemak dns
ip = socket.gethostbyname(hostname)
print(hostname, " IP ditemui:", ip)
print("Address Info: ", trace)
except socket.gaierror:
# jika dns tidak ditemui
print("DNS tidak ditemui")
# menjalankan fungsi
check_dns("www.google.com")
check_dns("www.example.com")
check_dns("www.mynic.my")
No comments:
Post a Comment