Created
December 8, 2011 16:40
-
-
Save jeroenvandijk/1447540 to your computer and use it in GitHub Desktop.
Baisc scraper with Aleph and Enlive
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
(defproject scraper "1.0.0-SNAPSHOT" | |
:dependencies [ | |
[org.clojure/clojure "1.2.1"] | |
[aleph "0.2.0"] | |
[enlive "1.0.0-SNAPSHOT"] | |
]) |
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
(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