I gave the code another look and remembered that *slurp* can actually handle a bunch of types as input, so I just passed the *InputStream *from the connection and got the same results. Additionaly in the code I posted before, the *get-response* function was never closing the stream, which * slurp* does.
(ns google-search (:import [java.net URL URLEncoder])) (def google-search-url "http://www.google.com/search?q=") (def user-agent "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172") (defn open-connection [url] (doto (.openConnection url) (.setRequestProperty "User-Agent" user-agent))) (defn get-response [url] (let [conn (open-connection url) sb (StringBuilder.)] (slurp (.getInputStream conn)))) (defn search [query] (let [url (java.net.URL. (str google-search-url (URLEncoder/encode query)))] (get-response url))) (spit "response.html" (search "clojure google")) J On Friday, March 22, 2013 1:02:53 PM UTC-3, Rich Morin wrote: > > On Mar 22, 2013, at 08:00, juan.facorro wrote: > > Setting the user agent did the trick, at least in my case. > > Thanks! Using your code, I was able to bring in a page and > write it to a file. I was then able to confirm that it had > the expected content. FTW! > > I still think this should be easier, but now I'm back on a > productive path. > > -r > > -- > http://www.cfcl.com/rdm Rich Morin > http://www.cfcl.com/rdm/resume r...@cfcl.com <javascript:> > http://www.cfcl.com/rdm/weblog +1 650-873-7841 > > Software system design, development, and documentation > > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.