Skip to content

Instantly share code, notes, and snippets.

@devn
Created March 19, 2014 23: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 devn/9654084 to your computer and use it in GitHub Desktop.
Save devn/9654084 to your computer and use it in GitHub Desktop.
(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