Skip to content

Commit

Permalink
* src/tutorial/scrape3.clj: added render-snippet to utils.clj, remove…
Browse files Browse the repository at this point in the history
…d html/selector usage from scrape3.clj
  • Loading branch information
swannodette committed Mar 28, 2010
1 parent f873314 commit 11eb293
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/tutorial/scrape3.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@
(def *base-url* "http://nytimes.com/")

(def *story-selector*
(html/selector [[:div.story
(html/but :.advertisement)
(html/but :.autosStory)
(html/but :.adCreative)]]))
[[:div.story
(html/but :.advertisement)
(html/but :.autosStory)
(html/but :.adCreative)]])

(def *headline-selector*
(html/selector #{[html/root :> :h2 :a],
[html/root :> :h3 :a]
[html/root :> :h5 :a]}))
#{[html/root :> :h2 :a],
[html/root :> :h3 :a]
[html/root :> :h5 :a]})

(def *byline-selector*
(html/selector [html/root :> :.byline]))
(def *byline-selector* [html/root :> :.byline])

(def *summary-selector*
(html/selector [html/root :> :.summary]))
(def *summary-selector* [html/root :> :.summary])

(defn fetch-url [url]
(html/html-resource (java.net.URL. url)))
Expand Down
3 changes: 3 additions & 0 deletions src/tutorial/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
(defn render [t]
(apply str t))

(defn render-snippet [s]
(apply str (html/emit* s)))

(defmulti parse-int type)
(defmethod parse-int java.lang.Integer [n] n)
(defmethod parse-int java.lang.String [s] (Integer/parseInt s))
Expand Down

0 comments on commit 11eb293

Please sign in to comment.