Hello
I'm playing with enlive to scrape some html. The code I produce feels a oddly messy and I'm wondering if I'm missing some conventions. (This is a total nitpick.)
The particular issue I see is that (select node css) args are ordered for thread first, but to process the resulting list of elements I want thread last maps.
For example
(def video-links
(-> list-url URL. html-resource
(select [:a.lecture-links])
#(map :attrs %)
#(map :data-model-iframe %)))
vs
(def video-links
(->> list-url URL. html-resource
#(select % [:a.lecture-links])
(map :attrs)
(map :data-model-iframe)))
vs
(def video-links
(->> (-> url URL. html-resource (select [:a.lecture-links]))
(map :attrs)
(map :data-model-iframe)))
vs
(def sel [n c] (select c n)
(def video-links
(->> (html-resource (URL. list-url))
(sel [:a.lecture-links])
(map :attrs)
(map :data-model-iframe)))
Perhaps, in hindsight, the api should have been defined with the args reversed?
cheers, Oliver