diff options
author | Joris | 2016-07-14 11:57:12 +0000 |
---|---|---|
committer | Joris | 2016-07-14 12:00:05 +0000 |
commit | 69e69017b75d1cdaa1fd2aef2818de5111b29735 (patch) | |
tree | 99dba8f67dc1c55b2cc22f33f81c59c7355b337b /src/Parser/Detail.hs | |
parent | 04f9a66c66ca137d9fee6ccca228c41fec960fe0 (diff) |
Update code and fix parsers
Diffstat (limited to 'src/Parser/Detail.hs')
-rw-r--r-- | src/Parser/Detail.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Parser/Detail.hs b/src/Parser/Detail.hs index 3f424e9..2418d07 100644 --- a/src/Parser/Detail.hs +++ b/src/Parser/Detail.hs @@ -1,5 +1,5 @@ module Parser.Detail - ( parseDetail + ( parse ) where import Data.Text (Text) @@ -16,18 +16,18 @@ import Model.Detail import Parser.Utils -parseDetail :: Text -> Detail -parseDetail page = +parse :: Text -> Detail +parse page = let tags = parseTags page in Detail { description = parseDescription tags - , images = getTagAttributes "<meta itemprop=image>" (T.pack "content") tags + , images = map (\url -> T.concat [T.pack "https:", url]) $ getTagAttributes "<meta itemprop=image>" (T.pack "content") tags , properties = parseProperties tags } parseDescription :: [Tag Text] -> Maybe Text parseDescription tags = - let descriptionTags = getTagsBetween "<div itemprop=description>" "</div>" tags + let descriptionTags = getTagsBetween "<p itemprop=description>" "</p>" tags in if null descriptionTags then Nothing @@ -37,7 +37,7 @@ parseDescription tags = parseProperties :: [Tag Text] -> Map Text Text parseProperties tags = - let mbUtagData = getTagTextAfter "<script>" . getTagsAfter "<body>" $ tags + let mbUtagData = getTagTextAfter "<script>" . getTagsAfter "</script>" . getTagsAfter "<body>" $ tags in fromMaybe M.empty (fmap parseUtagData mbUtagData) parseUtagData :: Text -> Map Text Text |