As a quick fix I suggest using the Apache httpclient library. You will need httpclient-4.x.x.jar, httpcore-4.x.x.jar and commons-logging-1.x.x.jar in your classpath, which you can find here:
- http://hc.apache.org/httpcomponents-client-ga/httpclient/index.html
- http://commons.apache.org/logging/
- http://hc.apache.org/
(ns apache-http (:import (org.apache.http.client ResponseHandler HttpClient methods.HttpGet) (org.apache.http.impl.client BasicResponseHandler DefaultHttpClient))) (defn http-get [ url ] (let [client (DefaultHttpClient.) httpget (HttpGet. url) handler (BasicResponseHandler.)] (try (let [body (.execute client httpget handler)] body) (catch Exception e (println e)) (finally (println "shutdown connection") (.shutdown (.getConnectionManager client)) )) ))
usage is simple:
(http-get "http://www.google.com")
No comments:
Post a Comment