Skip to content

Instantly share code, notes, and snippets.

Created June 16, 2009 07:33
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/8c22e987767b3563a3cb to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'open-uri'
url = 'http://ycombinator.com/faq.html'
body = open(url){|f| f.read}
link_text = body.match(/The ones that are currently launched are:.*?<p>/m).to_s
domains = link_text.gsub(/<!--.*?-->/m, '').scan(%r{<a href="http://([^"]+)"})
orgs = {}
domains.each do |c|
whois = `host -t a #{c} | grep 'has address' | cut -f 4 -d ' ' | xargs -n 1 whois`
org = if o = whois.grep(/OrgName/).first
o.sub(/OrgName:\s/, '').strip
else
whois.split("\n").first.split('(')[0].strip.sub(/\s+[A-Z\-\d]+$/, '')
end
(orgs[org] ||= []) << c
end
max_size = orgs.sort_by{|k, v| k.size}.last.first.size
orgs.sort_by{|k, v| v.size}.reverse.each do |o, ds|
puts "%-#{max_size}s %5s" % [o, ds.size]
ds.sort.each {|d| puts "\t#{d}"}
end
puts
puts "%-#{max_size}s %5s" % ["Total # of Domains", domains.size]
puts "%-#{max_size}s %5s" % ["Total # of Providers", orgs.size]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment