Created
January 17, 2011 01:42
-
-
Save CampingScorpion/782367 to your computer and use it in GitHub Desktop.
Enlive make screen scraping fun :)
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 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