File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 16
16
[migratus " 0.8.13" ]
17
17
[environ " 1.0.2" ]
18
18
[im.chit/hara.io.scheduler " 2.2.17" ]
19
- [im.chit/hara.time.joda " 2.2.17" ]]
19
+ [im.chit/hara.time.joda " 2.2.17" ]
20
+ [enlive " 1.1.6" ]]
20
21
21
22
:plugins [[migratus-lein " 0.2.6" ]]
22
23
Original file line number Diff line number Diff line change 1
1
(ns clojuretwbot.feed
2
2
(:require [clj-http.client :as http]
3
+ [net.cgrand.enlive-html :as html]
3
4
[taoensso.timbre :as timbre]
4
5
[feedparser-clj.core :as feedparser]
5
6
[clojure.string :as str]
17
18
(catch Exception e
18
19
(timbre/warn (.getMessage e)))))
19
20
21
+ (defn- parse-meta
22
+ " Parse HTML content's metadata."
23
+ [html property]
24
+ (-> html
25
+ (java.io.StringReader. )
26
+ (html/html-resource )
27
+ (html/select [[:meta (html/attr= :property property)]])
28
+ (first )
29
+ (get-in [:attrs :content ])))
30
+
20
31
(defn- parse-description
21
32
" Parse feed's og:description info, set :description to nil if not exist."
22
33
[info]
23
34
(let [html (or (fetch-html (:link info)) " " )
24
- description (-> (re-find #"(<meta\s *property=\" og:description\"\s *content=\" )(.*)(\" >)" html)
25
- (nth 2 ))]
35
+ description (parse-meta html " og:description" )]
26
36
(merge info {:description description})))
27
37
28
38
(defn- parse-feed
You can’t perform that action at this time.
0 commit comments