从 Clojure 中的 JSoup 文档中删除元素的最佳方法是什么(java 可变对象互操作性)?

What is the best way to delete elements from a JSoup Document in Clojure (java mutable object interoperability)?

完全是 Clojure 初学者。你如何在 Clojure 中访问变异的 jsoup 文档?我有下面的代码,我想打印出更改后的 html 而不是正在删除的链接。

(defn get-page []
  (.get (org.jsoup.Jsoup/connect "https://example.com")))

(defn -main
  "Fetch the page, delete links, and print out the html of the modified page"
  [& args]
  (let [html (get-page)]
   (println (.remove (.select html "a[href]")))))

@cfrick 在评论中回答了这个问题,所以我将其扩展为一个示例以使其更清楚。

让我们更改 -main 以在更改前后打印 html 中的值

(defn -main
  "Fetch the page, delete links, and print out the html of the modified page"
  [& args]
  (let [html (get-page)]
    (println "html before modification")
    (println html)

    (.remove (.select html "a[href]"))

    (println "html after modification")
    (println html)))