Skip to content

Instantly share code, notes, and snippets.

@beppu
Created October 6, 2014 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beppu/de0672f094ac1ceb286f to your computer and use it in GitHub Desktop.
Save beppu/de0672f094ac1ceb286f to your computer and use it in GitHub Desktop.
#lang racket
(require json)
(require net/http-client)
(define (4chan-data board x)
(let*-values
([(status headers res)
(http-sendrecv "a.4cdn.org"
(string-append "/" board "/" x ".json"))]
[(json) (read-string 1048576 res)]
[(page) (string->jsexpr json)])
page))
(define (4chan-data-page board n)
(4chan-data board (number->string n 10)))
(define (4chan-data-catalog board)
(4chan-data board "catalog"))
(define (4chan-thread-is-lisp-general? thread)
(and (hash-has-key? thread 'sub)
(regexp-match "Lisp General" (hash-ref thread 'sub))))
;; Usage
;; (define catalog (4chan-data-catalog "g"))
;; (filter 4chan-thread-is-lisp-general? (flatten (map (lambda (page) (hash-ref page 'threads)) catalog)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment