forked from filipg/twilight-library
Version 1.0
This commit is contained in:
parent
d8e664eba4
commit
03ffdeb1f7
15
app/aneks.hs
15
app/aneks.hs
@ -12,21 +12,22 @@ import Text.Regex.Posix
|
|||||||
import Text.Printf
|
import Text.Printf
|
||||||
|
|
||||||
|
|
||||||
extractRecords = extractLinksWithText "//a[contains(@title,'Aneks')]" -- pary tytuł-adres
|
extractRecords = extractLinksWithText "//a[contains(@title,'Aneks') and contains(text(),'Nr')]"
|
||||||
>>> first (arr $ replace "\r\n " " ") -- czyścimy pierwszy element pary, czyli tytuł z niepotrzebnych białych znaków
|
>>> second (arr $ replace "\r\n " " ")
|
||||||
>>> second (extractLinksWithText "//div/a[contains(@href,'.pdf')]") -- pobieramy stronę z adresu URL i wyciągamy linki z tej strony pasujące do wyrażenia XPathowego
|
>>> first (extractLinksWithText "//div/a[contains(@href,'.pdf')]") -- pobieramy stronę z adresu URL i wyciągamy linki z tej strony pasujące do wyrażenia XPathowego
|
||||||
-- ostatecznie wyjdą trójki? (Tytuł, (link do pdf, blank?))
|
-- ostatecznie wyjdą trójki? ((Link, tekst: "Wyświetl cały numer"), Numer Magazynu)
|
||||||
|
|
||||||
|
|
||||||
-- ... a tutaj te trójki przerabiamy do docelowej struktury ShadowItem
|
-- ... a tutaj te trójki przerabiamy do docelowej struktury ShadowItem
|
||||||
toShadowItem :: (String, (String, String)) -> ShadowItem
|
toShadowItem :: ((String, String), String) -> ShadowItem
|
||||||
toShadowItem (yearlyTitle, (url, blank)) =
|
toShadowItem ((url, blank), yearlyTitle) =
|
||||||
(defaultShadowItem url title) {
|
(defaultShadowItem url title) {
|
||||||
originalDate = Just date,
|
originalDate = Just date,
|
||||||
itype = "periodical",
|
itype = "periodical",
|
||||||
format = Just "pdf",
|
format = Just "pdf",
|
||||||
finalUrl = url
|
finalUrl = url
|
||||||
}
|
}
|
||||||
where title = yearlyTitle ++ " " ++ (replace "\r\n" "" (replace "\r\n " "" blank))
|
where title = yearlyTitle -- ++ " " ++ blank
|
||||||
date = getDate url
|
date = getDate url
|
||||||
|
|
||||||
getDate url =
|
getDate url =
|
||||||
|
@ -68,7 +68,7 @@ executable aneks
|
|||||||
build-depends: base
|
build-depends: base
|
||||||
, hxt
|
, hxt
|
||||||
, hxt-xpath
|
, hxt-xpath
|
||||||
, hxt-curl
|
, hxt-curl
|
||||||
, MissingH
|
, MissingH
|
||||||
, regex-posix
|
, regex-posix
|
||||||
, shadow-library
|
, shadow-library
|
||||||
|
Loading…
Reference in New Issue
Block a user