Advertisement
Guest User

Untitled

a guest
May 16th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. (ns rss.core
  2. (:gen-class)
  3. (:require [net.cgrand.enlive-html :as html]
  4. [clojure.string :as str]
  5. [manifold.deferred :as d]
  6. [byte-streams :as bs]
  7. [aleph.http :as http]
  8. [clj-rss.core :as rss]))
  9.  
  10. (defn fetch-html
  11. "Fetches the website html data"
  12. [url]
  13. (html/html-resource (java.net.URL. url)))
  14.  
  15. (def page-root
  16. (fetch-html "http://herald.dawn.com/in-depth"))
  17.  
  18. (def entries (html/select page-root [html/root :.story__link]))
  19.  
  20. (def xml (reduce str
  21. (map rss/channel-xml
  22. (map
  23. (fn [x]
  24. (let [content (:content x)
  25. link (:href (:attrs x))]
  26. {:title content
  27. :description "None"
  28. :link link}))
  29. entries))))
  30.  
  31. (defn -main
  32. [& args]
  33. (print xml))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement