Skip to content

Instantly share code, notes, and snippets.

@neidiom
Last active March 9, 2016 18:45
Show Gist options
  • Save neidiom/673af6ead1cb3dce2b20 to your computer and use it in GitHub Desktop.
Save neidiom/673af6ead1cb3dce2b20 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'httparty'
require 'json'
reddit_api_url = "http://www.reddit.com/r/funny/new.json?sort=new&limit=5"
resp = HTTParty.get(reddit_api_url)
data = JSON.parse(resp.body)
data['data']['children'].each do |sub|
puts "Title: #{sub['data']['title']}\n" << "Link: https://www.reddit.com#{sub['data']['permalink']}\n" << "URL: #{sub['data']['url']}\n\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment