Skip to content

Instantly share code, notes, and snippets.

@mbuckbee
Created December 11, 2010 20:08
Show Gist options
  • Save mbuckbee/737620 to your computer and use it in GitHub Desktop.
Save mbuckbee/737620 to your computer and use it in GitHub Desktop.
Deep search a single twitter users's history.
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