Python has everything else, but it doesn't have a nameserver lookup class. I propose creating a library which will perform the equivalent of the "dig" or "nslookup" commands. My own application is using it to query a DNS for mx records as a preface to using smtplib. (Perhaps this should be added to smtplib?)
dnslib? diglib? domainlib? nslookuplib?
Possibly: servers=dnsquery([nameserver],[name],[type],[class]) i.e.
from dnslib import dnsquery d=dnsquery(,"google.com","mx") print d
['10 smtp1.google.com','20 smtp2.google.com']
It would have the usual options, etc.
Is this a good idea or do I need to spend more time in the oven? (or worse, it already exists and I overlooked it?)
"John D." lists@webcrunchers.com writes:
Python has everything else, but it doesn't have a nameserver lookup class. I propose creating a library which will perform the equivalent of the "dig" or "nslookup" commands. My own application is using it to query a DNS for mx records as a preface to using smtplib. (Perhaps this should be added to smtplib?)
Is this a good idea or do I need to spend more time in the oven? (or worse, it already exists and I overlooked it?)
My dnspython package ( http://www.dnspython.org ) can do this, and a lot more. Here's a program which gets and prints MX records.
import dns.resolver
answers = dns.resolver.query('dnspython.org', 'MX') for rdata in answers: print 'Host', rdata.exchange, 'has preference', rdata.preference
/Bob