Created
July 31, 2020 21:27
-
-
Save jb3/fcced0ffbd4f715c83efdd0bc6acec25 to your computer and use it in GitHub Desktop.
This file contains 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 asyncio | |
import aiodns | |
loop = asyncio.get_event_loop() | |
resolver = aiodns.DNSResolver(loop=loop) | |
async def lookup(tld, data): | |
try: | |
data[tld] = await resolver.query(tld, "A") | |
except: | |
pass | |
with open("tlds-alpha-by-domain.txt", "r") as d: | |
tlds = d.read().split("\n")[::-1][1:][::-1] | |
data = {} | |
tasks = [] | |
async def main(): | |
tasks = [] | |
for tld in tlds: | |
tasks.append(loop.create_task(lookup(tld, data))) | |
await asyncio.gather(*tasks) | |
loop.run_until_complete(main()) | |
for tld, hosts in data.items(): | |
print(f".{tld}: {list(h.host for h in hosts)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a list of TLDs for those who need it: https://data.iana.org/TLD/tlds-alpha-by-domain.txt