Created
April 20, 2010 19:18
-
-
Save fronx/372924 to your computer and use it in GitHub Desktop.
search in twitter json records
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
| #! /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