Skip to content

Instantly share code, notes, and snippets.

@mururu
Created February 23, 2012 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mururu/1889379 to your computer and use it in GitHub Desktop.
Save mururu/1889379 to your computer and use it in GitHub Desktop.
# coding: utf-8
require "twitter"
def search(target)
result = []
(1..100).each do |i|
result << Twitter.search(target, :page => i, :rpp => 100) rescue break
end
iemon(result.flatten.uniq.sort_by(&:created_at).map(&:attrs))
end
def iemon(h)
[].tap do |result|
h.each do |t|
t["text"].sub!(/^RT @.+?: /, '') if t["text"] =~ /^RT @.+?: /
if f=result.select{|r|r[:text] == t["text"]}[0]
f[:rt] += 1
else
r = {:rt => 0, :text => t["text"], :created_at => t["created_at"], :url => "https://twitter.com/#!/#{t["from_user"]}/status/#{t["id"]}" }
result << r
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment