Last active
December 18, 2015 09:19
-
-
Save AyeGill/5760763 to your computer and use it in GitHub Desktop.
Simply get the text contents of wikipedia articles. Requires clj-http.
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
| (ns wikiget.core | |
| (:gen-class) | |
| (:require [clj-http.client :as client])) | |
| (defmacro pipeline | |
| ([x] x) | |
| ([x y] `(~y ~x)) | |
| ([x y & more] `(pipeline (~y ~x) ~@more))) | |
| (defn wikiget [name] | |
| "Get text contents of article" | |
| (pipeline (client/get (str "https://en.wikipedia.org/w/api.php?action=query&titles=" name "&prop=revisions&rvprop=content&format=json&redirects") | |
| {:as :json}) :body :query :pages vals first :revisions first :*)) | |
| (defn -main | |
| "Main function, read article title from command line and print it" | |
| [& args] | |
| (print (wikiget (first args)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment