public
Created

  • Download Gist
html.clj
Clojure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
(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)))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.