This commit is contained in:
Norbert Litkowski 2021-04-07 13:19:42 +02:00
parent 15c2e705b1
commit 0442a8c067

View File

@ -8,10 +8,12 @@ import Text.XML.HXT.XPath
import Data.List
import Data.List.Utils (replace)
import Text.Regex.Posix
-- import Text.Regex.Posix
import Text.Printf
import Control.Lens.Regex.Text
import Control.Lens.Regex
import Control.Lens
getLinkAndText xpathCondition = proc doc -> do
xpathTrees <- getXPathTrees xpathCondition -< doc
@ -48,12 +50,7 @@ toShadowItem (((url, releaseTitle), collectionTitle), categoryTitle) =
date = getDate $ releaseTitle
getDate yearlyTitle =
case yearlyTitle =~~ "/(19[0-9][0-9]|20[0-9][0-9])/" :: Maybe [[String]] of
Just [[_, year]] -> year
-- otherwise -> error $ "unexpected yearlyTitle: " ++ yearlyTitle
otherwise -> yearlyTitle
getDate txt = txt ^? [regex|19[0-9][0-9]|20[0-9][0-9]|] . match
main = do
let start = "http://zborbielawa.pl/archiwum/"