2022-04-14 16:10:57 +02:00
|
|
|
|
|
|
|
{-# LANGUAGE Arrows, NoMonomorphismRestriction #-}
|
|
|
|
import ShadowLibrary.Core
|
|
|
|
|
|
|
|
import Text.XML.HXT.Core
|
|
|
|
import Text.XML.HXT.XPath
|
|
|
|
-- import Text.XML.HXT.Curl
|
|
|
|
import Data.List
|
|
|
|
import Data.List.Utils (replace)
|
|
|
|
|
|
|
|
import Text.Regex.Posix
|
|
|
|
import Text.Printf
|
|
|
|
|
|
|
|
|
2022-05-05 13:46:32 +02:00
|
|
|
|
2022-05-10 00:20:35 +02:00
|
|
|
extractRecords = extractLinksWithText "//a[@class='title']"
|
|
|
|
>>> second (arr $ replace "\n\t\t\t\t\t" "")
|
|
|
|
>>> first (extractLinksWithText "//div[@class='title']"
|
|
|
|
>>> first (extractLinksWithText"//a[@class='obj_galley_link pdf']"))
|
|
|
|
-- >>> first (extractLinksWithText"//ul[@class='value galleys_links']//a[@class='obj_galley_link pdf']"))
|
2022-05-05 13:46:32 +02:00
|
|
|
-- ... a tutaj te trójki przerabiamy do docelowej struktury ShadowItem
|
2022-04-14 16:10:57 +02:00
|
|
|
|
2022-05-10 00:20:35 +02:00
|
|
|
toShadowItem :: (((String, String), String),String)-> ShadowItem
|
|
|
|
-- toShadowItem :: ((String, String),String) -> ShadowItem
|
|
|
|
-- toShadowItem ((url, articleTitle), yearlyTitle) =
|
|
|
|
toShadowItem (((url, articleTitle),pdfTitle), yearlyTitle)=
|
2022-04-14 16:10:57 +02:00
|
|
|
(defaultShadowItem url title) {
|
2022-05-05 13:46:32 +02:00
|
|
|
originalDate = Just date,
|
2022-04-14 16:10:57 +02:00
|
|
|
itype = "periodical",
|
|
|
|
format = Just "pdf",
|
|
|
|
finalUrl = url
|
|
|
|
}
|
|
|
|
|
2022-05-10 00:20:35 +02:00
|
|
|
where title = replace "\n\t\t\t" " " yearlyTitle ++ (replace "\t\n\t" "" (replace "\n\n\t" " " articleTitle)) ++ (replace "\n\t\t \n\t\t\t" " " (replace "\n\t\t\t\t\t \n\t" "" (replace "\n\t\t\t\t\t\t\t \n\t\t\t\t\t" " " (replace "\n\t\t\t\t " ""pdfTitle))))
|
|
|
|
date = getDate yearlyTitle
|
2022-05-05 13:46:32 +02:00
|
|
|
getDate yearlyTitle =
|
|
|
|
case yearlyTitle =~~ "(19[0-9][0-9]|20[0-9][0-9])" :: Maybe [[String]] of
|
2022-04-14 16:10:57 +02:00
|
|
|
Just [[_, year]] -> year
|
2022-05-05 13:46:32 +02:00
|
|
|
otherwise -> error $ "unexpected yearlyTitle " ++ yearlyTitle
|
2022-04-14 16:10:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
main = do
|
|
|
|
let start = "https://etyka.uw.edu.pl/index.php/etyka/issue/archive"
|
|
|
|
let start2 = "https://etyka.uw.edu.pl/index.php/etyka/issue/archive/2"
|
|
|
|
let start3 = "https://etyka.uw.edu.pl/index.php/etyka/issue/archive/3"
|
|
|
|
let shadowLibrary = ShadowLibrary {logoUrl=Nothing,
|
|
|
|
lname="Tom",
|
2022-05-10 00:20:35 +02:00
|
|
|
abbrev="Etyka",
|
2022-04-14 16:10:57 +02:00
|
|
|
lLevel=0,
|
|
|
|
webpage=start}
|
|
|
|
extractItemsStartingFromUrl shadowLibrary start (extractRecords >>> arr toShadowItem)
|
|
|
|
extractItemsStartingFromUrl shadowLibrary start2 (extractRecords >>> arr toShadowItem)
|
|
|
|
extractItemsStartingFromUrl shadowLibrary start3 (extractRecords >>> arr toShadowItem)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-05 13:46:32 +02:00
|
|
|
|