Search code examples
clojureweb-scrapingenlive

Parsing snippets of html with enlive


Why does the following snippet does not work?

(html/select (:body (client/post "http://www.web.onpe.gob.pe/modElecciones/elecciones/elecciones2011/2davuelta/onpe/presidente/extras/provincias.php" {:form-params {"elegido" "010000"}})) [:option])

Do I have to do something with the html-string to turn it into a clojure datastructure first or something like that?


Solution

  • Yep - you can use html/html-snippet to turn a raw html string into something enlive can use, or html/html-resource to use an entire html file.

    Try the following:

    (html/select 
      (html/html-snippet 
        (:body (client/post "<your-website>" {:form-params {"elegido" "010000"}})) 
      [:option])