diff options
author | Joris | 2016-07-14 11:57:12 +0000 |
---|---|---|
committer | Joris | 2016-07-14 12:00:05 +0000 |
commit | 69e69017b75d1cdaa1fd2aef2818de5111b29735 (patch) | |
tree | 99dba8f67dc1c55b2cc22f33f81c59c7355b337b /src/Page.hs | |
parent | 04f9a66c66ca137d9fee6ccca228c41fec960fe0 (diff) |
Update code and fix parsers
Diffstat (limited to 'src/Page.hs')
-rw-r--r-- | src/Page.hs | 13 |
1 files changed, 7 insertions, 6 deletions
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) |