Mercurial > feed
annotate tests/reddit.ur @ 23:e1e451cf85bb
Simplify Reddit example more
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 29 Sep 2012 10:34:11 -0400 |
parents | 923e097e9ba3 |
children |
rev | line source |
---|---|
adam@21 | 1 fun main () = |
adam@21 | 2 doc <- Feed.fetch "http://www.reddit.com/?limit=30"; |
adam@21 | 3 |
adam@23 | 4 ls <- Feed.app' (Feed.tree (Feed.tagAOR "div" {DataUps = "data-ups", Class = "class"} {Style = "style"}) |
adam@23 | 5 (Feed.tagAOR "a" {Href = "href", Class = "class"} {Style = "style"})) |
adam@23 | 6 (fn (div, a) ls => |
adam@23 | 7 return (if not (String.isPrefix {Full = div.Class, Prefix = " thing "}) |
adam@23 | 8 || Option.isSome (String.sindex {Haystack = div.Class, Needle = "promoted"}) |
adam@23 | 9 || div.Style = Some "display:none" |
adam@23 | 10 || a.Class <> "title " |
adam@23 | 11 || a.Style = Some "display:none" then |
adam@23 | 12 ls |
adam@23 | 13 else |
adam@23 | 14 a.Href :: ls)) |
adam@23 | 15 doc []; |
adam@21 | 16 |
adam@21 | 17 return <xml><body> |
adam@21 | 18 <h1>Top 30 Reddit Links</h1> |
adam@21 | 19 |
adam@21 | 20 <ol> |
adam@23 | 21 {List.mapX (fn url => <xml><li>{[url]}</li></xml>) (List.rev ls)} |
adam@21 | 22 </ol> |
adam@21 | 23 </body></xml> |