/YC Company Hosting Stats Secret
Created
June 16, 2009 07:33
Star
You must be signed in to star a gist
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
#!/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