Created
September 3, 2016 09:39
-
-
Save iokiwi/b294f7713c9d824f5063a289912cf5c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys, urllib.request | |
| url = "https://data.iana.org/TLD/tlds-alpha-by-domain.txt" | |
| local_filename, headers = urllib.request.urlretrieve(url) | |
| tlds = open(local_filename).readlines() | |
| tlds = [tld.strip() for tld in tlds] | |
| if len(sys.argv) > 1: | |
| domain = sys.argv[1] | |
| else: | |
| domain = input("Enter a domain name: ") | |
| substitunion_count = 0 | |
| for tld in tlds: | |
| tld = tld.lower() | |
| if domain.lower().endswith(tld): | |
| substitunion_count += 1 | |
| print(domain[:domain.index(tld)] + "." + tld) | |
| if substitunion_count == 0: | |
| print("No top level domain name substitutions were found") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment