blob: bd73912a2601d0595e41cf02c8ce85c0de790c14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
module Parser.Resume
( parseResumes
) where
import Data.Maybe (catMaybes)
import Text.HTML.TagSoup
import Model.Resume
import Parser.Utils
parseResumes :: String -> [Resume]
parseResumes page =
case sections (~== "<div class=list-lbc>") (parseTags page) of
[] ->
[]
sectionTags : _ ->
let lbcTags = takeWhile (~/= "<div id=alertesCartouche>") sectionTags
in catMaybes . fmap parseResume $ partitions (~== "<a>") lbcTags
parseResume :: [Tag String] -> Maybe Resume
parseResume item = do
name <- getTagText "<h2 class=title>" item
let price = getTagText "<div class=price>" item
url <- getTagAttribute "<a>" "href" item
return Resume { name = name, price = price, url = url }
|