Created
June 19, 2009 19:01
-
-
Save huned/132793 to your computer and use it in GitHub Desktop.
homework in 8 minutes
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
require 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
# First find the rss | |
url = ARGV[1] || "http://twitter.com/burnto" | |
doc = Hpricot(open(url)) | |
rss_url = doc.search("link[@type=\"application/rss+xml\"]").first.attributes["href"] | |
doc = Hpricot(open(rss_url)) | |
counts = {} | |
doc.search("item/pubdate").each{|d| | |
t = Time.parse(d.inner_html) | |
date = [t.year, t.month, t.day].join("/") | |
counts.has_key?(date) ? counts[date] += 1 : counts[date] = 1 | |
} | |
counts.keys.sort.each do |date| | |
print date | |
counts[date].times do print "=" end | |
print "\n" | |
end | |
# 2009/6/15=== | |
# 2009/6/16======= | |
# 2009/6/17====== | |
# 2009/6/18=== | |
# 2009/6/19= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment