From f38b6b716b20dafcbf43b804194b5b8f519e4caa Mon Sep 17 00:00:00 2001 From: kuba Date: Mon, 18 Apr 2022 11:15:43 +0200 Subject: [PATCH] msl robot --- app/msl.hs | 67 +++++++++++++++++++++++++++++++++++++++++ packages.microsoft.gpg | Bin 0 -> 641 bytes stack.yaml.lock | 19 ++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 app/msl.hs create mode 100644 packages.microsoft.gpg create mode 100644 stack.yaml.lock diff --git a/app/msl.hs b/app/msl.hs new file mode 100644 index 0000000..deb3f6f --- /dev/null +++ b/app/msl.hs @@ -0,0 +1,67 @@ + +{-# 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 + + +extractH xpathCondition = (downloadDocument &&& this) + >>> first(getXPathTrees xpathCondition + >>> (listA (deep isText >>> getText) + >>> arr (intercalate " ") + )) + +extractInfo xpathCondition = (downloadDocument &&& this) + >>> first (getXPathTrees xpathCondition + >>> (getAttrValue "href" + &&& (getXPathTrees "//a[@class='msl-box-link']//div[@class='msl-box-title']" + >>> (listA (deep isText >>> getText)) + >>> arr (intercalate " ") + ) + &&& (getXPathTrees "//a[@class='msl-box-link']//div[@class='msl-box-info']" + >>> (listA (deep isText >>> getText)) + >>> arr (intercalate " ") + ) + &&& (getXPathTrees "//a[@class='msl-box-link']//div[@class='time']" + >>> (listA (deep isText >>> getText)) + >>> arr (intercalate " ") + ) + )) + + + +extractRecords = extractInfo "//a[@class='msl-box-link']" + + + +toShadow :: ((String, (String, (String, String))), String) -> ShadowItem +toShadow ((url, (title, (author, year))), s) = + ShadowItem { + url = Just url, + title = title, + originalDate = Just year, + creator = Just author, + format = Just s, + itype = "periodical", + lang = Nothing, + finalUrl = url, + description = Nothing + } + + +main = do + --let start = "https://zasoby.msl.org.pl/mobjects/show" + let start = "https://zasoby.msl.org.pl/mobjects/show?date_range=&otype%5B4%5D=1&otype%5B5%5D=1&otype%5B6%5D=1&otype%5B7%5D=1" --przefiltrowane + let shadowLibrary = ShadowLibrary {logoUrl=Nothing, + lname="Zasoby MSL", + abbrev="MSL", + lLevel=0, + webpage=start} + extractItemsStartingFromUrl shadowLibrary start (extractRecords >>> arr toShadow) diff --git a/packages.microsoft.gpg b/packages.microsoft.gpg new file mode 100644 index 0000000000000000000000000000000000000000..0cffae08d061d6ae8959b4442dd2dbce26c340e8 GIT binary patch literal 641 zcmV-{0)G9O0SyFJF<6WN2mrt;hGAw>aTw8-&ZU0T;kCvj9-@p2hRX&3tKIp#mk44K zWSkQ%c4{HQA}s#tsn;1=(LHS^JIEF`F{wkR(&D>9o|7yP=~Y+NKK3;C`4axI=rYyq zrB<*k)BskBDEsDx5Yd^pAvz|*XxLN^Rs1tKcJz?E$yQpt@e`p4a|{c zMCET7wg8i5k#M`dMmXStEMdYRelqXC@i+Karv74@Qsaue67_2{MmJAUtPq zXLDs^b#iHRc|dJxV{&hEZ)S8ZV{dIfi2*eP69EDM9|ZzdF<6WO8v_Ol2?z%R0t6KT z2m=Ea0s#UZ0Rk6*0162Z>pqmNz7i?V8k-0IeXlDmy&evAAJ<zH{duFkO6N3 z&j)GB_6-&>FO*4L(_oK+UEBCNPtqruWb}jtrH<