Oczyszczenie pola title
This commit is contained in:
parent
88872ec6aa
commit
d28c055f3b
@ -12,27 +12,31 @@ import Text.Regex.Posix
|
||||
import Text.Printf
|
||||
|
||||
|
||||
|
||||
extractRecords = extractLinksWithText "//a[@class='title']" -- pary adres-tytuł
|
||||
>>> second (arr $ replace "\r\n " "")-- czyścimy drugi element pary, czyli tytuł z niepotrzebnych białych znaków
|
||||
>>> second (arr $ replace "\n\t\t\t\t\t" "")-- czyścimy drugi element pary, czyli tytuł z niepotrzebnych białych znaków
|
||||
>>> first (extractLinksWithText "//a[@class='obj_galley_link 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) {
|
||||
originalDate = Just yearlyTitle,
|
||||
originalDate = Just date,
|
||||
itype = "periodical",
|
||||
format = Just "pdf",
|
||||
finalUrl = url
|
||||
}
|
||||
where title = yearlyTitle ++ " " ++ (replace "\r\n" "" (replace "\r\n " "" articleTitle))
|
||||
date = getDate url
|
||||
|
||||
getDate url =
|
||||
case url =~~ "/([0-9]+)/" :: Maybe [[String]] of
|
||||
where title = replace "\n\t\t\t" "" yearlyTitle ++ " " ++ (replace "\n\n\t" "" (replace "\n\n\t\t\n\t" " " articleTitle))
|
||||
date = getDate yearlyTitle
|
||||
|
||||
getDate yearlyTitle =
|
||||
case yearlyTitle =~~ "(19[0-9][0-9]|20[0-9][0-9])" :: Maybe [[String]] of
|
||||
Just [[_, year]] -> year
|
||||
otherwise -> error $ "unexpected url: " ++ url
|
||||
otherwise -> error $ "unexpected yearlyTitle " ++ yearlyTitle
|
||||
|
||||
|
||||
main = do
|
||||
|
Loading…
Reference in New Issue
Block a user