Skip to content

Instantly share code, notes, and snippets.

@ninoseki
Created June 20, 2019 16:53
Show Gist options
  • Save ninoseki/e4b4a1a06174f51630028a05eca258f2 to your computer and use it in GitHub Desktop.
Save ninoseki/e4b4a1a06174f51630028a05eca258f2 to your computer and use it in GitHub Desktop.
Grab the latest TLDs
# frozen_string_literal: true
require "http"
TLD_LIST = "https://data.iana.org/TLD/tlds-alpha-by-domain.txt"
def tlds
res = HTTP.get(TLD_LIST)
return [] if res.code != 200
res.body.to_s.lines.reject do |line|
line.start_with? "#"
end.map do |line|
line.chomp.downcase
end
end
tlds.each do |tld|
puts tld
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment