Now we will use dnspython to find the same details of a web URL that we earlier found using dig and host commands.
Listing 11.3 gives a simple, yet verbose code to offer the details of resource records of a given URL:
#!/usr/bin/env python # Python Network Programming Cookbook, Second Edition -- Chapter - 11 # This program is optimized for Python 2.7.12 and Python 3.5.2. # It may run on any other version with/without modifications. import argparse import dns.zone import dns.resolver import socket def main(address): # IPv4 DNS Records answer = dns.resolver.query(address, 'A') for i in xrange(0, len(answer)): print("Default: ", answer[i]) # IPv6 DNS Records try: answer6 = dns.resolver.query(address, 'AAAA') for i in xrange(0, ...