From 69e69017b75d1cdaa1fd2aef2818de5111b29735 Mon Sep 17 00:00:00 2001 From: Joris Date: Thu, 14 Jul 2016 11:57:12 +0000 Subject: Update code and fix parsers --- src/Page.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Page.hs') diff --git a/src/Page.hs b/src/Page.hs index 443f768..8a8ebea 100644 --- a/src/Page.hs +++ b/src/Page.hs @@ -1,21 +1,22 @@ module Page - ( getPage + ( get ) where import Control.Exception (SomeException, try) import Data.Text (Text) import qualified Data.Text as T +import Data.Text.Encoding as T +import Data.ByteString.Lazy as BS -import Network.HTTP (simpleHTTP, getRequest, getResponseBody) +import Network.HTTP.Conduit import Model.URL import Utils.Either (mapLeft) -getPage :: URL -> IO (Either Text Text) -getPage url = - mapLeft (T.pack . show) <$> (try (unsafeGetPage url) :: IO (Either SomeException Text)) +get :: URL -> IO (Either Text Text) +get url = mapLeft (T.pack . show) <$> (try (unsafeGetPage url) :: IO (Either SomeException Text)) unsafeGetPage :: URL -> IO Text -unsafeGetPage url = simpleHTTP (getRequest (T.unpack url)) >>= (\x -> T.pack <$> getResponseBody x) +unsafeGetPage url = (T.decodeLatin1 . BS.toStrict) <$> simpleHttp (T.unpack url) -- cgit v1.2.3