这个使用代码的简单代码片段dnspython
将名称解析为 IP。
在此示例中,域是google.com
A 记录的答案。如何在一个查询中获取多条记录(例如 TXT、CNAME、..)?
from dns.resolver import dns
myResolver = dns.resolver.Resolver() #create a new instance named 'myResolver'
myAnswers = myResolver.query("google.com", "A") #Lookup the 'A' record(s) for google.com
for rdata in myAnswers: #for each response
print (rdata) #print the data