Skip to content

Instantly share code, notes, and snippets.

@rixth
Created January 27, 2010 00:39
Show Gist options
  • Save rixth/287419 to your computer and use it in GitHub Desktop.
Save rixth/287419 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# Search a users previous 3200 for a keyword.
unless ARGV.size == 2
puts "USAGE: look-for-tweet.rb username terms"
Process.exit
end
username = ARGV.first
terms = ARGV.last
require 'rexml/document'
for i in (1..1000) do
xml = `curl -s "http://twitter.com/statuses/user_timeline/#{username}.xml?count=200&page=#{i}"`
doc = REXML::Document.new(xml)
num_tweets = 0
doc.elements.each('statuses/status') do |e|
puts e.elements["text"].text if e.elements["text"].text[term]
++num_tweets
end
Process.exit unless num_tweets
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment