Created
June 20, 2019 16:53
-
-
Save ninoseki/e4b4a1a06174f51630028a05eca258f2 to your computer and use it in GitHub Desktop.
Grab the latest TLDs
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
# 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