Skip to content

Instantly share code, notes, and snippets.

@AyeGill
Last active December 18, 2015 09:19
Show Gist options
  • Select an option

  • Save AyeGill/5760763 to your computer and use it in GitHub Desktop.

Select an option

Save AyeGill/5760763 to your computer and use it in GitHub Desktop.
Simply get the text contents of wikipedia articles. Requires clj-http.
(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