Skip to content

Instantly share code, notes, and snippets.

@raek
Created April 13, 2012 17:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raek/2378475 to your computer and use it in GitHub Desktop.
Save raek/2378475 to your computer and use it in GitHub Desktop.
(ns se.raek.html
(:import [org.ccil.cowan.tagsoup.jaxp SAXFactoryImpl])
(:require [clojure.xml :as xml]))
(defn startparse-tagsoup [s ch]
(.. (new SAXFactoryImpl) (newSAXParser) (parse s ch)))
(defn parse [s]
(xml/parse s startparse-tagsoup))
(defn title [h]
(let [head-content (-> h :content first :content)]
(-> (filter (fn [node] (= (:tag node) :title))
head-content)
first :content first .trim)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment