diff options
author | Joris | 2018-06-18 21:51:51 +0200 |
---|---|---|
committer | Joris | 2018-06-18 21:51:51 +0200 |
commit | 96bbdbbe9b22b3c3e96998cc18a3b68c9db66da9 (patch) | |
tree | 1a5e5e1b8d44c0a7dad614a1a0d5c7886a585d17 /src/executable/haskell/Utils | |
parent | 3717598bb16a23097bbe1b4e676fd4e781eec640 (diff) |
Fix ouest france ads encoding
Diffstat (limited to 'src/executable/haskell/Utils')
-rw-r--r-- | src/executable/haskell/Utils/HTTP.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/executable/haskell/Utils/HTTP.hs b/src/executable/haskell/Utils/HTTP.hs index c901500..919e66d 100644 --- a/src/executable/haskell/Utils/HTTP.hs +++ b/src/executable/haskell/Utils/HTTP.hs @@ -3,18 +3,17 @@ module Utils.HTTP ) where import Control.Exception (SomeException, try) - -import Data.ByteString.Lazy as BS +import Data.ByteString (ByteString) +import qualified Data.ByteString.Lazy as BS import Data.Text (Text) import qualified Data.Text as T -import Data.Text.Encoding as T import Network.HTTP.Conduit import Model.URL import Utils.Either (mapLeft) -get :: URL -> IO (Either Text Text) -get url = mapLeft (T.pack . show) <$> (try (unsafeGetPage url) :: IO (Either SomeException Text)) +get :: (ByteString -> Text) -> URL -> IO (Either Text Text) +get decode url = mapLeft (T.pack . show) <$> (try (unsafeGetPage decode url) :: IO (Either SomeException Text)) -unsafeGetPage :: URL -> IO Text -unsafeGetPage url = (T.decodeLatin1 . BS.toStrict) <$> simpleHttp (T.unpack url) +unsafeGetPage :: (ByteString -> Text) -> URL -> IO Text +unsafeGetPage decode url = (decode . BS.toStrict) <$> simpleHttp (T.unpack url) |