Created
April 13, 2012 17:21
-
-
Save raek/2378475 to your computer and use it in GitHub Desktop.
This file contains 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 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