public
Last active

Enlive make screen scraping fun :)

  • Download Gist
enlive-screen-scraping.clj
Clojure
1 2 3 4 5 6 7 8 9 10
(ns screen-scraping
(:use [clojure.contrib.duck-streams :only [reader]]
[net.cgrand.enlive-html :only [html-resource select text]]))
 
(def url-to-scrape "http://www.domain.com/somewhere/index.php")
 
;; finds the text of the element with id="someId"
(defn scrape []
(let [html (-> url-to-scrape reader html-resource)]
(-> html (select [:#someid]) first text)))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.