Skip to content

Instantly share code, notes, and snippets.

@CoderPrans
Last active July 13, 2021 21:11
Show Gist options
  • Save CoderPrans/77b7d3fbb286a73e75fe5181708c678e to your computer and use it in GitHub Desktop.
Save CoderPrans/77b7d3fbb286a73e75fe5181708c678e to your computer and use it in GitHub Desktop.
ba.bash.ka script to download SICP
#!/usr/bin/env bb
(require '[babashka.curl :as curl])
(def sicp-url "https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/")
(def pages (map #(str "book-Z-H-" % ".html" ) (rest (range 39))))
(def data (map #(vector (str sicp-url %) %) pages))
(defn get-url [url]
(println "Downloading url:" url)
(curl/get url))
(defn write-html [file html]
(println "Writing file:" file)
(spit file html))
(map
(fn [[url file]]
(write-html file (:body (get-url url))))
data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment