I also include a list of 100 domains in a domains.txt if anyone wants to try for themselves.
require "socket"
require "celluloid"
class IPGetter
include Celluloid
def get(url)
Socket.getaddrinfo(url, "http")[0][2]
end
end
pool = IPGetter.pool(size: 100)
ips = {}
File.open("domains.txt").each_line do |line|
line.chomp!
ips[line] = pool.future.get(line)
end
ips.each do |url, ip_future|
puts "#{url} => #{ip_future.value}"
end
https://gist.github.com/a803d86234e8d1fc5496
I also include a list of 100 domains in a domains.txt if anyone wants to try for themselves.