Created
December 5, 2012 20:43
-
-
Save fallengiants/4219318 to your computer and use it in GitHub Desktop.
4chan api helpers
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
| def get_raw_json_from(url) | |
| Net::HTTP.get(URI.parse(url)) | |
| end | |
| def get_json_from(url) | |
| Hashie::Mash.new(JSON.parse(get_raw_json_from(url))) | |
| end | |
| def get_board(board, page) | |
| get_json_from "http://api.4chan.org/#{board}/#{page}.json" | |
| end | |
| def get_post(board, thread_number) | |
| get_json_from "http://api.4chan.org/#{board}/res/#{thread_number}.json" | |
| end | |
| def get_raw_board(board, page) | |
| get_raw_json_from "http://api.4chan.org/#{board}/#{page}.json" | |
| end | |
| def get_raw_post(board, thread_number) | |
| get_raw_json_from "http://api.4chan.org/#{board}/res/#{thread_number}.json" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment