blob: 76faca4c229937ea2b02abd8f2e17193b08aa94e (
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
28
29
|
module Parser.Resume
( parseResumes
) where
import Data.Maybe (catMaybes)
import Data.Text (Text)
import qualified Data.Text as T
import Text.HTML.TagSoup
import Model.Resume
import Parser.Utils
parseResumes :: Text -> [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 Text] -> Maybe Resume
parseResume item = do
name <- getTagTextAfter "<h2 class=title>" item
let price = getTagTextAfter "<div class=price>" item
url <- getTagAttribute "<a>" (T.pack "href") item
return Resume { name = name, price = price, url = url }
|