twitterのAPI制限が糞なのでRubyでtwitterのpublic_htmlをScrapした。

require 'kconv'
require 'rubygems'
require 'hpricot'
require 'open-uri'

$Kcode = 'u'

doc = Hpricot.parse(open("http://twitter.com/public_timeline"))
doc.search("tr.hentry").each { |entrys|

  entry = Hpricot.parse(entrys.to_s.toutf8)
  name = entry.search("td.content strong").inner_text.to_s.gsub(/[ |\t|\n]/,"")
  comment = entry.search("span.entry-content").inner_text.to_s.gsub(/[ |\t|\n]/,"")
  warn name + ":" + comment

}    

API使わずに直接Scrapするとサーバに負荷を与えるのでループでまわしたりはやめた方がいいね。


追記:
twitterの構造が変ったのでこれは使えません。