module Ad
( getAds
) where
import Text.HTML.TagSoup (parseTags)
import Page (getPage)
import Model.Ad
import Model.Resume
import Model.Detail
import Parser.Resume
import Parser.Detail
getAds :: String -> IO (Either String [Ad])
getAds url = do
eitherPage <- getPage url
case eitherPage of
Left error ->
return (Left error)
Right page ->
getAdsFromPage page
getAdsFromPage :: String -> IO (Either String [Ad])
getAdsFromPage page = do
xs <- sequence $ map getAd (parseResumes page)
return $ sequence xs
getAd :: Resume -> IO (Either String Ad)
getAd resume = do
page <- getPage (url resume)
fmap (\page -> Ad { resume = resume, detail = parseDetail (parseTags page)}) <$> getPage (url resume)