Зачем я это сделал?
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as T
import Text.HTML.DOM (parseLBS)
import Text.XML.Cursor
import Text.XML (Element(Element), Node(NodeElement, NodeContent) )
import Network.HTTP.Conduit
import Text.Printf
import System.Environment
fmt reply = printf "[%s] %s\n%s\n" id name body
where
str (NodeElement (Element "br" _ _)) = [T.pack "\n"]
str (NodeContent x) = [x]
str _ = []
text x = T.unpack $ T.strip $ T.concat $ reply $// x >=> descendant >=> str.node
id = text $ element "span" >=> attributeIs "class" "reflink"
name = text $ element "span" >=> attributeIs "class" "postername"
body = text $ element "blockquote"
gogogo url = cursor >>= sequence_ . (>>= return.putStrLn.fmt) . replies
where
cursor = simpleHttp url >>= return.fromDocument.parseLBS
replies body = body $// element "td" >=> attributeIs "class" "reply"
main = getArgs >>= mapM_ gogogo