Skip to content

Instantly share code, notes, and snippets.

@zelark
Created February 16, 2021 06:34
Show Gist options
  • Save zelark/6b6434402109a823a6a963d263dc7b21 to your computer and use it in GitHub Desktop.
Save zelark/6b6434402109a823a6a963d263dc7b21 to your computer and use it in GitHub Desktop.
#grumpy
(defn posts-after [post-id]
(slurp (str "https://grumpy.website/after/" post-id)))
(defn get-post-ids [posts]
(->> posts
(re-seq #"data\-id=\"(.+?)\"")
(map second)))
(defn post-ids [start-id]
(loop [post-ids [start-id]
posts (posts-after start-id)]
(if-let [ids (seq (get-post-ids posts))]
(do (future (prn ids))
(recur (into post-ids ids)
(posts-after (last ids))))
post-ids)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment