Created
October 1, 2012 11:16
-
-
Save lambdaman2/3811030 to your computer and use it in GitHub Desktop.
Impromptu: parse rss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (load "xml_lib.scm") | |
| (define feedurl "http://feeds.guardian.co.uk/theguardian/world/rss") | |
| ;; | |
| ;; loads the feed and extracts title and url | |
| ;; | |
| ;; | |
| (define get-articles-online | |
| (lambda () | |
| (let* ((out '()) | |
| (feed (xml:load-url feedurl)) | |
| (titles (objc:nsarray->list (xml:xpath (xml:get-root-node feed) | |
| "channel/item/title/text()"))) | |
| (urls (objc:nsarray->list (xml:xpath (xml:get-root-node feed) | |
| "channel/item/link/text()")))) | |
| (for-each (lambda (x y) | |
| (let ((xx (objc:nsstring->string x)) | |
| (yy (objc:nsstring->string y))) | |
| (set! out (append out (list (list xx yy)))))) | |
| titles urls) | |
| out))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment