Created
March 19, 2014 23:42
-
-
Save devn/9654084 to your computer and use it in GitHub Desktop.
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
(defn write-file [filename file] | |
(with-open [w (clojure.java.io/output-stream filename)] | |
(.write w (:body file)))) | |
(let [base-uri "http://google.com" | |
img-path (-> (get-page base-uri) | |
(first-by-xpath "//img[@alt='Google']") | |
(comp :src attrs)) | |
img-url (str base-uri img-path)] | |
(->> (clj-http.client/get img-uri {:as :byte-array | |
:follow-redirects true}) | |
(write-file "google-homepage.png"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment