Mercurial > feed
view 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 |
line wrap: on
line source
fun main () = doc <- Feed.fetch "http://www.reddit.com/?limit=30"; ls <- Feed.app' (Feed.tree (Feed.tagAOR "div" {DataUps = "data-ups", Class = "class"} {Style = "style"}) (Feed.tagAOR "a" {Href = "href", Class = "class"} {Style = "style"})) (fn (div, a) ls => return (if not (String.isPrefix {Full = div.Class, Prefix = " thing "}) || Option.isSome (String.sindex {Haystack = div.Class, Needle = "promoted"}) || div.Style = Some "display:none" || a.Class <> "title " || a.Style = Some "display:none" then ls else a.Href :: ls)) doc []; return <xml><body> <h1>Top 30 Reddit Links</h1> <ol> {List.mapX (fn url => <xml><li>{[url]}</li></xml>) (List.rev ls)} </ol> </body></xml>