Skip to content

Instantly share code, notes, and snippets.

@jhmaster2000
Last active May 24, 2022 06:39
Show Gist options
  • Save jhmaster2000/1acf6669efaf19ad13b4eebc9d12182b to your computer and use it in GitHub Desktop.
Save jhmaster2000/1acf6669efaf19ad13b4eebc9d12182b to your computer and use it in GitHub Desktop.
IANA TLD List Fetcher
import fs from 'fs';
import got from 'got'; // npm install got
got.get('https://data.iana.org/TLD/tlds-alpha-by-domain.txt').then(response => {
const listData = response.body.split('\n');
const listVersion = listData.shift()!.slice(2);
listData.pop();
fs.writeFileSync('./tlds.json', JSON.stringify({ version: listVersion, tlds: listData }));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment