Skip to content

Instantly share code, notes, and snippets.

@samsm
Created December 28, 2009 01:14
Show Gist options
  • Save samsm/264475 to your computer and use it in GitHub Desktop.
Save samsm/264475 to your computer and use it in GitHub Desktop.
# 1. Install CouchDBX. Fire it up. (OS X only.)
# 2. sudo gem install couchrest json
# 3. Think up a nice keyword.
# 4. irb
require 'couchrest'
require 'open-uri'
require 'json'
database_name = 'twitter-test'
@db = CouchRest.database!("http://127.0.0.1:5984/#{database_name}")
twitter_search_url = "http://search.twitter.com/search.json?"
keyword = 'couchdb'
(1..10).each do |n|
JSON.parse(open("#{twitter_search_url}q=#{keyword}&rpp=100&page=#{n}").read)['results'].each do |post|
@db.save_doc(post)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment