Skip to content

Instantly share code, notes, and snippets.

@lambdahands lambdahands/
Last active May 21, 2018

What would you like to do?
Clojure + Java

Run this script

Call this in your terminal:

$ clj -Sdeps '{:deps {hello {:git/url "" :sha "02b5ca5c86a800829c6f4aeaf0f83ed016cef49c"}}}' -m hello
{:paths ["."]
:deps {org.jsoup/jsoup {:mvn/version "1.11.3"}}} ;; Importing a Java library
(ns hello
(:require [ :as io])
(:import [org.jsoup Jsoup]))
(def html-string (slurp (io/resource "test.html")))
(def parsed-html (Jsoup/parse html-string))
(def foo-elements (.getElementsByClass parsed-html "foo"))
(defn -main []
(doseq [element foo-elements]
(println (.text element))))
<div class="foo">Hello</div>
<div class="foo">World!</div>
<div class="foo">Clojure is dope</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.