Welcome to the CHICKEN Scheme pasting service

kuh.scm pasted by wasamasa on Thu Apr 16 23:10:12 2015

(use (only http-client with-input-from-request)
     (only html-parser html->sxml)
     sxpath)

(define (burger-der-woche)
  (let* ((base-url "https://www.facebook.com/DiefetteKuh")
         (document-html (with-input-from-request base-url #f html->sxml))
         (fragment-sxpath (sxpath "//code[contains(comment(), 'BURGER')]"))
         (fragment-tree (fragment-sxpath document-html))
         (fragment-comment (car (alist-ref '*COMMENT* (cdar fragment-tree))))
         (fragment (call-with-input-string fragment-comment html->sxml))
         (description-sxpath (sxpath "//div[contains(@class, 'userContent')]/p"))
         (description-tree (description-sxpath fragment))
         (description-paragraph (car description-tree)))
    (string-concatenate (filter string? description-paragraph))))

(print (burger-der-woche))

burger-der-woche using zippers! added by DerGuteMoritz on Sun May 3 20:15:13 2015

(define comment?
  (tag= '*COMMENT*))

(define (burger-comment? x)
  (and (comment? x)
       (find-first x (lambda (y)
                       (let ((n (node y)))
                         (and (string? n)
                              (string-contains n "BURGER")))))))

(define (burger-der-woche)
  (and-let* ((base-url "https://www.facebook.com/DiefetteKuh")
             (document-html (with-input-from-request base-url #f html->sxml))
             (document (sxml-zipper document-html))
             (fragment-comment (find-first document burger-comment?))
             (fragment-html (call-with-input-string (text fragment-comment) html->sxml))
             (fragment (sxml-zipper fragment-html))
             (description-tree (find-first fragment (has-class "userContent")))
             (description-paragraph (find-first description-tree (tag= 'p))))
    (text description-paragraph)))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which operator can be represented by an apostrophe?
Visually impaired? Let me spell it for you (wav file) download WAV