require 'open-uri' require 'json' url = 'http://search.twitter.com/search.json?q=edinburgh+jobs&rpp=5&include_entities=true&result_type=mixed' buffer = open(url, "UserAgent" => "Ruby-Wget").read # convert JSON data into a hash json = JSON.parse(buffer) result = json['results'].map do |tweet| [tweet['from_user_name'], tweet['text']] end result.each {|x| puts ("%+6s: %s" % x)}