我有一个小的脚本,用于检查大量的MX记录域列表,一切正常,但是当脚本找到没有记录的域时,跳到下一个域要花很长时间.
我尝试添加:
query.lifetime = 1.0
or
query.timeout = 1.0
但这似乎无能为力.有谁知道如何配置此设置?
我的脚本在下面,谢谢您的宝贵时间.
import dns.resolver
from dns.exception import DNSException
import dns.query
import csv
domains = csv.reader(open('domains.csv', 'rU'))
output = open('output.txt', 'w')
for row in domains:
try:
domain = row[0]
query = dns.resolver.query(domain,'MX')
query.lifetime = 1.0
except DNSException:
print "nothing here"
for rdata in query:
print domain, " ", rdata.exchange, 'has preference', rdata.preference
output.writelines(domain)
output.writelines(",")
output.writelines(rdata.exchange.to_text())
output.writelines("
")