Skip to content

Instantly share code, notes, and snippets.

@fronx
Created April 20, 2010 19:18
Show Gist options
  • Select an option

  • Save fronx/372924 to your computer and use it in GitHub Desktop.

Select an option

Save fronx/372924 to your computer and use it in GitHub Desktop.
search in twitter json records
#! /usr/bin/env ruby
require 'rubygems'
require 'json'
@user, @q = ARGV[0], ARGV[1]
puts "searching '#{@user}' for '#{@q}'"
def tweets
result = []
(1..50).to_a.each do |page|
begin
data = File.open("#{@user}.#{page}.json").read
result += JSON.parse(data)
rescue => e
# puts e.message
end
end
result.map { |tweet| tweet['id'].to_s + ': ' + tweet['text'] }
end
puts tweets.grep(/#{@q}/i).join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment