January 2019
Beginner to intermediate
776 pages
19h 58m
English
We import dns.name of dnspython to do a simple exercise to find the DNS names from the user inputs of two web URLs, and how these web URLs are related.
Listing 11.1 evaluates the user input of two web URLs for the DNS names as follows:
#!/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.name
def main(site1, site2):
_site1 = dns.name.from_text(site1)
_site2 = dns.name.from_text(site2)
print("site1 is subdomain of site2: ", _site1.is_subdomain(_site2))
print("site1 is superdomain of site2: ", _site1.is_superdomain(_site2)) print("site1 ...Read now
Unlock full access