Hello Mike,
Take a look at hickory, it's more straightforward than enlive if you want
to find something in html: https://github.com/davidsantiago/hickory
(ns ......
(:require [hickory.core :as h]
[hickory.select :as hs]
[cljs.core.async :as a]))
let [html (:body (a/<! (http/get url)))
parsed (-> html h/parse h/as-hickory)
inputs (hs/select
(hs/and
(hs/tag :input)
(hs/attr :href #(re-find #"sop://" %)))
parsed)]
Best regards,
Eduard
On Thursday, October 15, 2015 at 8:00:23 PM UTC+3, Mike wrote:
>
> I've read the clojure.data.xml.zip docs carefully and looked at many
>> examples, but I don't understand this behavior:
>>
>
> (require '[clj-http.client :as client]
> '[clojure.zip :as z]
> '[clojure.data.zip :as dz]
> '[clojure.data.zip.xml :as dzx]
> '[crouton.html :as html])
> (def my-html "<html>\n<body>\n<input src='a.png'/>\n</body>\n</html>")
> (def my-zipper (z/xml-zip (html/parse-string my-html)))
> (dzx/xml1-> my-zipper)
> (dzx/xml1-> my-zipper dz/descendants)
> (dzx/xml1-> my-zipper :html)
>
> I am starting with this so that I can understand step-by-step what is
> happening here. I built a simple HTML string, converted it into an XML
> zipper and then tried a few *xml1 *calls on it:
>
> (dzx/xml1-> my-zipper)
>
> gives me the original zipper, which is what I expected.
>
> (dzx/xml1-> my-zipper dz/descendants)
>
> gives me what appears to be the original zipper structure, which I wasn't
> expecting. I was expecting a flattened-out seq of the nodes.
>
> (dzx/xml1-> my-zipper :html)
>
> returns *nil*, which I *really *wasn't expecting. Examples on the web
> led me to believe that this last call should match on the html tag. Can
> anyone provide any explanation on these call and why I got these return
> values?
>
>
>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.