Created
October 2, 2013 14:19
-
-
Save samueldowens/6794504 to your computer and use it in GitHub Desktop.
reddit SFW
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
| require 'json' | |
| require 'rest_client' | |
| reddit_hash = JSON.parse(RestClient.get('http://reddit.com/.json')) | |
| over_18 = [] | |
| title = [] | |
| reddit_url = [] | |
| thumbnail = [] | |
| upvotes = [] | |
| downvotes = [] | |
| n = 0 | |
| while reddit_hash["data"]["children"].length > n do | |
| over_18 << reddit_hash["data"]["children"][n]["data"]["over_18"] | |
| title << reddit_hash["data"]["children"][n]["data"]["title"] | |
| reddit_url << reddit_hash["data"]["children"][n]["data"]["permalink"] | |
| thumbnail << reddit_hash["data"]["children"][n]["data"]["thumbnail"] | |
| upvotes << reddit_hash["data"]["children"][n]["data"]["ups"] | |
| downvotes << reddit_hash["data"]["children"][n]["data"]["downs"] | |
| n += 1 | |
| end | |
| i = 0 | |
| title.length.times do |x| | |
| puts "" | |
| puts "<html>" | |
| puts " <head>" | |
| puts " </head>" | |
| puts " <body>" | |
| puts " <ul>" | |
| puts " <li>" | |
| puts " <a href=\"#{reddit_url[i]}\">" | |
| puts " <h1>#{title[i]}</h1>" | |
| puts " <img src=\"#{thumbnail[i]}\"/>" | |
| puts " <h4>Upvotes:</p>" | |
| puts " <p>#{upvotes[i]}</h4>" | |
| puts " <p>Downvotes:</p>" | |
| puts " <h4>#{downvotes[i]}</h4>" | |
| puts " </a>" | |
| puts " </ul>" | |
| puts " </body>" | |
| puts " </html>" | |
| puts "" | |
| i += 1 | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment