diff --git a/app/instytutTechnikiGorniczej.hs b/app/instytutTechnikiGorniczej.hs index 58347b4..44d0f3e 100644 --- a/app/instytutTechnikiGorniczej.hs +++ b/app/instytutTechnikiGorniczej.hs @@ -11,17 +11,18 @@ import Data.List.Utils (replace) import Text.Regex.Posix import Text.Printf -extractRecords = extractLinksWithText "//li/a[contains(@href,'/lata')]" - >>> second (arr $ replace "\r\n " " ") - >>> first (extractLinksWithText "//p/a[contains(@href, '/archiwum/images/gazety')]") -toShadowItem :: ((String, String), String) -> ShadowItem -toShadowItem ((url, articleTitle), yearlyTitle) = +extractRecords = extractLinksWithText "//li/a[contains(@href,'/lata')]" + >>> first (extractLinksWithText "//li/a[contains(@href,'start=')]" + >>> first (extractLinksWithText "//a[contains(@href, '/archiwum/images/19') or contains(@href, '/Trybuna')]")) + + +toShadowItem :: (((String, String), String), String) -> ShadowItem +toShadowItem (((url, articleTitle), _), yearlyTitle) = (defaultShadowItem url title) { originalDate = Just date, itype = "periodical", format = Just form, --- format = Just "pdf", finalUrl = url } where title = "Instytut Techniki Gorniczej " ++ yearlyTitle ++ " " ++ (replace "\r\n" "" (replace "\r\n " "" articleTitle)) @@ -29,10 +30,10 @@ toShadowItem ((url, articleTitle), yearlyTitle) = form = unwords $ map stringToLower [getFormat url] getDate url = - case url =~~ "(19[0-9][0-9]|20[0-9][0-9])" :: Maybe [[String]] of + case url =~~ "(19[0-9][0-9]|20[0-9][0-9]).*\\..{3}" :: Maybe [[String]] of Just [[_, year]] -> year otherwise -> error $ "unexpected url: " ++ url - + getFormat url = case url =~~ "([a-zA-Z]+$)" :: Maybe [[String]] of Just [[_, format]] -> format