I've got a script that gets DNS (CNAME, MX, NS) data in the following way:
from dns import resolver
...
def resolve_dns(url):
response_dict = {}
print "\nResolving DNS for %s" % (url)
try:
response_dict['CNAME'] = [rdata for rdata in resolver.query(url, 'CNAME')]
except:
pass
try:
response_dict['MX'] = [rdata for rdata in resolver.query(url, 'MX')]
except:
pass
try:
response_dict['NS'] = [rdata for rdata in resolver.query(url, 'NS')]
except:
pass
return response_dict
This function is being called sequentially for successive URLs. If possible, I'd like to speed up the above process by getting the data for multiple URLs simultaneously.
Is there a way to accomplish what the above script does for a batch of URLs (perhaps returning a list of dict objects, with each dict corresponding to the data for a particular a URL)?