Created
December 11, 2010 20:08
-
-
Save mbuckbee/737620 to your computer and use it in GitHub Desktop.
Deep search a single twitter users's history.
This file contains hidden or 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 'twitter' | |
require 'json' | |
require 'net/http' | |
def term_search(screen_name, needle) | |
(0..9999999).each do |i| | |
puts "Page #{i} Search" | |
url = "http://api.twitter.com/1/statuses/user_timeline.json?page=#{i}&screen_name=#{screen_name}" | |
resp = Net::HTTP.get_response(URI.parse(url)) | |
data = resp.body | |
result = JSON.parse(data) | |
result.each do |status| | |
if status["text"].include?(needle) | |
puts status["text"] + " - " + "http://twitter.com/#{screen_name}/status/#{status["id"]}" | |
end | |
end | |
sleep(3) | |
end | |
end | |
term_search("mbuckbee","@codinghorror") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment