Skip to content

Instantly share code, notes, and snippets.

@robashton
Created June 7, 2012 10:50
Show Gist options
  • Select an option

  • Save robashton/2888176 to your computer and use it in GitHub Desktop.

Select an option

Save robashton/2888176 to your computer and use it in GitHub Desktop.
(ns foo.core
(:use [net.cgrand.enlive-html :as html])
)
(def BASEURL "https://en.wikipedia.org/wiki/")
(defn fetch-url [url]
(html/html-resource (java.net.URL. url)))
(defn define
"Fetches a page from wikipedia and prints the first paragraph"
[q]
(let [url (str BASEURL q)
content (fetch-url url)]
((comp html/text
first
html/select) content [:#mw-content-text :p])
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment