Skip to content

Instantly share code, notes, and snippets.

@ipl31
Created January 23, 2011 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipl31/792366 to your computer and use it in GitHub Desktop.
Save ipl31/792366 to your computer and use it in GitHub Desktop.
quick and dirty ysql query function, returns json
def yql_query_json(query)
api_query = CGI.escape(query)
url = "http://query.yahooapis.com/v1/public/yql?q=#{api_query}&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env"
json_results = open(url) {|f| f.read}
results = JSON.parse(json_results)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment