Skip to content

Instantly share code, notes, and snippets.

@jb3
Created July 31, 2020 21:27
Show Gist options
  • Save jb3/fcced0ffbd4f715c83efdd0bc6acec25 to your computer and use it in GitHub Desktop.
Save jb3/fcced0ffbd4f715c83efdd0bc6acec25 to your computer and use it in GitHub Desktop.
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)}")
@vcokltfre
Copy link

Here's a list of TLDs for those who need it: https://data.iana.org/TLD/tlds-alpha-by-domain.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment