Last active
November 4, 2015 04:55
-
-
Save cjwinchester/2d807e458a344325b634 to your computer and use it in GitHub Desktop.
A Python script to fetch a current list of top-level domains from IANA.
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 requests | |
| import json | |
| def getDomainList(): | |
| url = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt" | |
| r = requests.get(url) | |
| s = r.text.split("\n") | |
| date = s[0].split("Last Updated ")[1] | |
| js = {} | |
| clean_list = [] | |
| for dude in s[1:]: | |
| if dude != "": | |
| clean_list.append(dude.lower().strip()) | |
| js['updated_date'] = date | |
| js['domains'] = clean_list | |
| return json.dumps(js) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment