我正在尝试从http://egonschiele.github.io/HandsomeSoup/获取基本示例来工作:
main = do
doc <- fromUrl "http://www.google.com/search?q=egon+schiele"
links <- runX $ doc >>> css "h3.r a" ! "href"
mapM_ putStrLn links
我试图像这样重现这个例子:
module Main (main) where
import Text.HandsomeSoup
import Text.XML.HXT.Core
import Control.Monad
main = do
doc <- fromUrl "http://www.google.com/search?q=egon+schiele"
links <- runX $ doc >>> css "h3.r a" ! "href"
mapM_ putStrLn links
但是,我收到以下错误:
$ runhaskell Main.hs
Main.hs:8:21:
Couldn't match expected type `IOSLA (XIOState ()) XmlTree b0'
with actual type `hxt-9.3.0.1:Data.Tree.NTree.TypeDefs.NTree
hxt-9.3.0.1:Text.XML.HXT.DOM.TypeDefs.XNode'
In the first argument of `(>>>)', namely `doc'
In the second argument of `($)', namely
`doc >>> css "h3.r a" ! "href"'
In a stmt of a 'do' block:
links <- runX $ doc >>> css "h3.r a" ! "href"
但我真的无法弄清楚发生了什么。