From 8883a924b4c9bf81b4670f3a4e9fb04831646301 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Sat, 13 Mar 2021 18:31:04 +0100 Subject: [PATCH] Add comments --- app/almanachmuszyny.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/almanachmuszyny.hs b/app/almanachmuszyny.hs index 1cf9c4d..ebc4f5c 100644 --- a/app/almanachmuszyny.hs +++ b/app/almanachmuszyny.hs @@ -11,11 +11,14 @@ import Data.List.Utils (replace) import Text.Regex.Posix import Text.Printf -extractRecords = extractLinksWithText "//a[@class='roczniki']" - >>> second (arr $ replace "\r\n " "") - >>> first (arr ((++"tr") . init)) - >>> first (extractLinksWithText "//li/a[contains(@href,'.pdf')]") +extractRecords = extractLinksWithText "//a[@class='roczniki']" -- pary adres-tytuł + >>> second (arr $ replace "\r\n " " ") -- czyścimy drugi element pary, czyli tytuł z niepotrzebnych białych znaków + >>> first (arr ((++"tr") . init)) -- modyfikujemy pierwszy element pary, czyli adres URL + >>> first (extractLinksWithText "//li/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 ((adres URL, tytuł artykułu), tytuł rocznika) + +-- ... a tutaj te trójki przerabiamy do docelowej struktury ShadowItem toShadowItem :: ((String, String), String) -> ShadowItem toShadowItem ((url, articleTitle), yearlyTitle) = (defaultShadowItem url title) {