aboutsummaryrefslogtreecommitdiff
path: root/src/Page.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Page.hs')
-rw-r--r--src/Page.hs13
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)