
How to take screenshots and generate PDFs in Clojure
How to Take Screenshots and Generate PDFs in Clojure Clojure has no native headless browser. Options on the JVM include Java interop to Selenium WebDriver, calling a Node.js subprocess for Puppeteer, or etaoin (a WebDriver library). All require a running browser and complicate deployment. Here's the simpler path: one HTTP call, binary response. Fits naturally into Clojure's data-oriented style. Using clj-http clj-http is the most common synchronous HTTP client in the Clojure ecosystem: ;; deps.edn { :deps { clj-http/clj-http { :mvn/version "3.13.0" } cheshire/cheshire { :mvn/version "5.13.0" }}} ( ns myapp.pagebolt ( :require [ clj-http.client :as http ] [ cheshire.core :as json ])) ( def ^ :private base-url "https://pagebolt.dev/api/v1" ) ( defn- api-key [] ( System/getenv "PAGEBOLT_API_KEY" )) ( defn screenshot [ url & { :keys [ full-page? block-banners? ] :or { full-page? true block-banners? true }}] ( :body ( http/post ( str base-url "/screenshot" ) { :headers { "x-api-key" ( api-k
Continue reading on Dev.to Webdev
Opens in a new tab

