Sample code for 30+ languages & platforms
Chilkat2-Python

DNS Lookup

Do a DNS lookup to resolve a hostname to an IP address.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

socket = chilkat2.Socket()

maxWaitMs = 10000
ipAddr = socket.DnsLookup("www.chilkatsoft.com",maxWaitMs)
if (socket.LastMethodSuccess != True):
    print(socket.LastErrorText)
    sys.exit()

print("IP Address: " + ipAddr)