Sensible high-level DNS lookups in Python, using DNSpython resolver. Version 1.8.1 provides an easy-to-use wrapper around dnspython for common DNS queries (A, AAAA, MX, NS, TXT, etc.). It is released under MIT license and maintained on GitHub. Release cadence is low, with occasional updates.
pip install nslookupVerified import paths — ran on the pinned version, not inferred.
Initialize NsLookup with a list of DNS servers, then call methods like .a() or .mx() to perform lookups. The result object contains .answer, .response_full, etc.
Always pass a list of DNS servers, e.g., NsLookup(dns_servers=['8.8.8.8']).
Use the new specific methods (e.g., .a(), .mx(), .aaaa(), .ns(), .txt()) instead of the generic .dns_lookup().
Wrap calls in try/except blocks or implement retry logic with alternative servers.