Skip to content

Instantly share code, notes, and snippets.

@AlexBaranosky
Created January 17, 2011 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexBaranosky/782367 to your computer and use it in GitHub Desktop.
Save AlexBaranosky/782367 to your computer and use it in GitHub Desktop.
Enlive make screen scraping fun :)
(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)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment