Skip to content

Instantly share code, notes, and snippets.

@jeroenvandijk
Created December 8, 2011 16:40
Show Gist options
  • Save jeroenvandijk/1447540 to your computer and use it in GitHub Desktop.
Save jeroenvandijk/1447540 to your computer and use it in GitHub Desktop.
Baisc scraper with Aleph and Enlive
(defproject scraper "1.0.0-SNAPSHOT"
:dependencies [
[org.clojure/clojure "1.2.1"]
[aleph "0.2.0"]
[enlive "1.0.0-SNAPSHOT"]
])
(require 'lamina.core 'aleph.http 'aleph.formats 'net.cgrand.enlive-html)
(defn handler [resp]
(let [body-channel (lamina.core/map* aleph.formats/bytes->input-stream(:body resp))]
(lamina.core/receive body-channel #(println (net.cgrand.enlive-html/select (net.cgrand.enlive-html/html-resource %) [:a])))))
(lamina.core/async
(handler (aleph.http/http-request {:method :get :url "http://slashdot.org"})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment