diff options
Diffstat (limited to 'src/lib/haskell/FetchAd.hs')
-rw-r--r-- | src/lib/haskell/FetchAd.hs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/lib/haskell/FetchAd.hs b/src/lib/haskell/FetchAd.hs new file mode 100644 index 0000000..a206181 --- /dev/null +++ b/src/lib/haskell/FetchAd.hs @@ -0,0 +1,36 @@ +module FetchAd + ( leboncoin + , ouestFrance + , seLoger + ) where + +import Data.Either (rights) +import Data.Text.Encoding as T + +import Model.Ad (Ad) +import Model.URL (URL) +import qualified Parser.LeboncoinParser as LeboncoinParser +import qualified Parser.OuestFranceParser as OuestFranceParser +import qualified Parser.SeLogerParser as SeLogerParser +import qualified Utils.HTTP as HTTP + +leboncoin :: [URL] -> IO [Ad] +leboncoin urls = + fmap (concat . map LeboncoinParser.parse . rights) + . sequence + . map (HTTP.get T.decodeLatin1) + $ urls + +ouestFrance :: [URL] -> IO [Ad] +ouestFrance urls = + fmap (concat . map OuestFranceParser.parse . rights) + . sequence + . map (HTTP.get T.decodeUtf8) + $ urls + +seLoger :: [URL] -> IO [Ad] +seLoger urls = + fmap (concat . map SeLogerParser.parse . rights) + . sequence + . map (HTTP.get T.decodeUtf8) + $ urls |