Robot for Teatr Lalek
This commit is contained in:
parent
8883a924b4
commit
953d7242e8
37
app/teatrLalek.hs
Normal file
37
app/teatrLalek.hs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
{-# 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
|
||||||
|
|
||||||
|
|
||||||
|
extractRecords = extractLinks "//a[contains(@href, '.pdf')]"
|
||||||
|
|
||||||
|
|
||||||
|
toShadowItem :: String -> ShadowItem
|
||||||
|
toShadowItem url =
|
||||||
|
(defaultShadowItem url []) {
|
||||||
|
originalDate = Just date,
|
||||||
|
itype = "periodical",
|
||||||
|
format = Just "pdf",
|
||||||
|
finalUrl = url
|
||||||
|
}
|
||||||
|
where
|
||||||
|
date = last $ getAllTextMatches $ url =~ "(19[0-9][0-9]|20[0-9][0-9])" :: String
|
||||||
|
|
||||||
|
|
||||||
|
main = do
|
||||||
|
let start = "http://polunima.pl/teatr-lalek/"
|
||||||
|
let shadowLibrary = ShadowLibrary {logoUrl=Nothing,
|
||||||
|
lname="Teatr Lalek",
|
||||||
|
abbrev="Teatr",
|
||||||
|
lLevel=0,
|
||||||
|
webpage=start}
|
||||||
|
extractItemsStartingFromUrl shadowLibrary start (extractRecords >>> arr toShadowItem)
|
Loading…
Reference in New Issue
Block a user