Created
February 22, 2010 05:16
-
-
Save swannodette/310820 to your computer and use it in GitHub Desktop.
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 littlesis.names | |
(:require [net.cgrand.enlive-html :as html])) | |
(def *base-url* "http://blog.littlesis.org/2010/02/18/sources-allege-goldman-sachs-and-john-paulson-are-partnering-in-speculative-attacks-o\ | |
n-greece/") | |
(defn fetch-url [url] | |
(html/html-resource (java.net.URL. url))) | |
(defn entry [node] | |
(first (html/select node [:div.entry]))) | |
;; could probably be better expressed as reduce | |
(defn text-nodes [node] | |
(let [content (:content node)] | |
(loop [subnode (first content) nodes (rest content) result []] | |
(if (nil? subnode) | |
result | |
(if (= (type subnode) java.lang.String) | |
(recur (first nodes) (rest nodes) (conj result subnode)) | |
(recur (first nodes) (rest nodes) (into result (text-nodes subnode)))))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment