Search code examples
clojureenlive

Reading web page with log in (clojure)


I need to download some contents of a web page daily and I plan on using enlive for that. Trouble is, that I need to log in in with a POST first and the authentification of the page that I am interested in is then done with the session's cookies. So I can't just use

(html/html-resource (java.net.URL. url))

I didn't find a way to do this in clojure. Otherwise doing the reading in Java would be fine as well. In the end it should work as a worker on heroku.

Thanks!


Solution

  • You need an http-client to create a valid session. You can use clj-http's Cookie Store to simplify maintaining the cookie across requests.