Skip to content

Instantly share code, notes, and snippets.

@paultag
Created June 26, 2013 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save paultag/5864063 to your computer and use it in GitHub Desktop.
Save paultag/5864063 to your computer and use it in GitHub Desktop.
;;; Hy tumblr printer.
;;; Copyright (c) Paul R. Tagliamonte, 2013, MIT/Expat license.
(import [urllib2 [urlopen]]
[lxml [etree]]
[sys [argv]])
(defn get-rss-feed-name [tumblr]
(kwapply (.format "http://{tumblr}.tumblr.com/rss") {"tumblr" tumblr}))
(defn get-rss-feed [tumblr]
(.parse etree (urlopen (get-rss-feed-name tumblr))))
(defn print-posts [tumblr]
(for [post (.xpath (get-rss-feed tumblr) "//item/title")]
(print post.text)))
(if (slice argv 2)
(print-posts (get argv 2))
(print-posts "this-plt-life"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment