Clojure 如何使用Enliven解析HTML?

Clojure 如何使用Enliven解析HTML?,clojure,enlive,Clojure,Enlive,下面是一个使用Enlive的解析。这两种方法会有区别吗 如果在这个简单的例子中没有太多的差异,那么在做一些网页抓取时,Enlivive会有什么不同呢 谢谢 (ns parse.enlive (:require [net.cgrand.enlive-html :as html])) (def ^:dynamic *base-url* "https://news.ycombinator.com/") (defn fetch-url [url] (html/html-resource (j

下面是一个使用Enlive的解析。这两种方法会有区别吗

如果在这个简单的例子中没有太多的差异,那么在做一些网页抓取时,Enlivive会有什么不同呢

谢谢

(ns parse.enlive
  (:require [net.cgrand.enlive-html :as html]))

(def ^:dynamic *base-url* "https://news.ycombinator.com/")

(defn fetch-url [url]
  (html/html-resource (java.net.URL. url)))

(defn hn-headlines []
  (map html/text (html/select (fetch-url *base-url*) [:td.title :a])))

(defn hn-points []
  (map html/text (html/select (fetch-url *base-url*) [:td.subtext html/first-child])))

(defn print-headlines-and-points []
  (doseq [line (map #(str %1 " (" %2 ")") (hn-headlines) (hn-points))]
    (println line)))