[Haskell-cafe] Help on simpleHttp in Network.HTTP.Conduit problem
Stuart Mills
stuartallenmills at gmail.com
Tue Jan 21 22:39:36 UTC 2014
Here is the source by the way:
{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Conduit (simpleHttp)
import qualified Data.Text as T
import Text.HTML.DOM (parseLBS)
import Text.XML.Cursor (Cursor, attributeIs, content, element,
fromDocument, child,
($//), (&|), (&//), (>=>))
-- The URL we're going to search
url = "http://www.bing.com/search?q=school+of+haskell"
-- The data we're going to search for
findNodes :: Cursor -> [Cursor]
findNodes = element "span" >=> attributeIs "id" "count" >=> child
-- Extract the data from each node in turn
extractData = T.concat . content
-- Process the list of data elements
processData = putStrLn . T.unpack . T.concat
cursorFor :: String -> IO Cursor
cursorFor u = do
page <- simpleHttp u
return $ fromDocument $ parseLBS page
-- test
main = do
cursor <- cursorFor url
processData $ cursor $// findNodes &| extractData
On Tuesday, January 21, 2014 2:10:19 PM UTC-8, Stuart Mills wrote:
>
> I copied and pasted some html parsing demo source from FP School.
>
> While the code works on the FP demo site (in the IDE), I get the following
> error on my Windows 7 64 bit:
>
> InternalIOException getAddrInfo: does not exist (error 10093).
>
> Thanks
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140121/acaf4af4/attachment.html>
More information about the Haskell-Cafe
mailing list