forked from filipg/twilight-library
Compare commits
No commits in common. "master" and "master" have entirely different histories.
50
.vscode/tasks.json
vendored
50
.vscode/tasks.json
vendored
@ -1,50 +0,0 @@
|
||||
|
||||
{
|
||||
// Automatically created by phoityne-vscode extension.
|
||||
|
||||
"version": "2.0.0",
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new"
|
||||
},
|
||||
"tasks": [
|
||||
{
|
||||
// F7
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"label": "haskell build",
|
||||
"type": "shell",
|
||||
//"command": "cabal configure && cabal build"
|
||||
"command": "stack build"
|
||||
},
|
||||
{
|
||||
// F6
|
||||
"group": "build",
|
||||
"type": "shell",
|
||||
"label": "haskell clean & build",
|
||||
//"command": "cabal clean && cabal configure && cabal build"
|
||||
"command": "stack clean && stack build"
|
||||
//"command": "stack clean ; stack build" // for powershell
|
||||
},
|
||||
{
|
||||
// F8
|
||||
"group": {
|
||||
"kind": "test",
|
||||
"isDefault": true
|
||||
},
|
||||
"type": "shell",
|
||||
"label": "haskell test",
|
||||
//"command": "cabal test"
|
||||
"command": "stack test"
|
||||
},
|
||||
{
|
||||
// F6
|
||||
"isBackground": true,
|
||||
"type": "shell",
|
||||
"label": "haskell watch",
|
||||
"command": "stack build --test --no-run-tests --file-watch"
|
||||
}
|
||||
]
|
||||
}
|
@ -33,7 +33,7 @@ import Data.Tree.NTree.TypeDefs
|
||||
import Data.Maybe
|
||||
import Control.Monad.Trans
|
||||
import Text.XML.HXT.XPath
|
||||
import Text.XML.HXT.Curl
|
||||
-- import Text.XML.HXT.Curl
|
||||
import Text.XML.HXT.HTTP
|
||||
|
||||
import Text.Regex.TDFA
|
||||
@ -64,8 +64,8 @@ downloadDocument = readFromDocument [withParseHTML yes,
|
||||
withEncodingErrors no,
|
||||
withPreserveComment yes,
|
||||
withStrictInput yes,
|
||||
-- withHTTP,
|
||||
withCurl [("curl--user-agent","AMU Digital Libraries Indexing Agent")]
|
||||
withHTTP []
|
||||
-- withCurl [("curl--user-agent","AMU Digital Libraries Indexing Agent")]
|
||||
]
|
||||
|
||||
downloadDocumentWithEncoding enc = readFromDocument [withParseHTML yes,
|
||||
@ -73,13 +73,13 @@ downloadDocumentWithEncoding enc = readFromDocument [withParseHTML yes,
|
||||
withEncodingErrors no,
|
||||
withPreserveComment yes,
|
||||
withInputEncoding enc,
|
||||
-- withHTTP,
|
||||
withCurl [("curl--user-agent","AMU Digital Libraries Indexing Agent")]]
|
||||
withHTTP []]
|
||||
-- withCurl []]
|
||||
|
||||
downloadXmlDocument = readFromDocument [withWarnings no,
|
||||
withEncodingErrors no,
|
||||
-- withHTTP,
|
||||
withCurl [("curl--user-agent","AMU Digital Libraries Indexing Agent")]]
|
||||
withHTTP []]
|
||||
-- withCurl [] ]
|
||||
|
||||
|
||||
data ShadowLibrary = ShadowLibrary { logoUrl :: Maybe String,
|
||||
|
@ -1,50 +0,0 @@
|
||||
|
||||
{-# 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.TDFA
|
||||
-- import Text.Regex.TDFA.Text ()
|
||||
import Text.Regex.Posix
|
||||
import Text.Printf
|
||||
|
||||
extractRecords = extractLinksWithText "//h3[@class='media-heading']/a"
|
||||
>>> first (arr (++"/issue/archive"))
|
||||
>>> first (extractLinksWithText "//*[@class='media-heading']/a"
|
||||
>>> first (extractLinksWithText "//*[@class='media-heading']/a"
|
||||
>>> first (extractLinks "//div[@class='download']/a"
|
||||
>>> extractLinks "//a[@class='download']")))
|
||||
|
||||
toShadowItem :: (((String, String), String), String) -> ShadowItem
|
||||
toShadowItem (((url, articleTitle), yearlyTitle), journalTitle) =
|
||||
(defaultShadowItem url title) {
|
||||
originalDate = Just date,
|
||||
itype = "periodical",
|
||||
format = Just "pdf",
|
||||
finalUrl = url
|
||||
}
|
||||
where title = replace "\n" "" (replace "\t" "" (journalTitle ++ " " ++ yearlyTitle ++ " " ++ 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 text: " ++ yearlyTitle
|
||||
|
||||
getDate :: String -> String
|
||||
getDate yearlyTitle = date where
|
||||
date = yearlyTitle Text.Regex.TDFA.=~ "(19[0-9][0-9]|20[0-9][0-9])" :: String
|
||||
|
||||
|
||||
main = do
|
||||
let start = "https://pressto.amu.edu.pl"
|
||||
let shadowLibrary = ShadowLibrary {logoUrl=Nothing,
|
||||
lname="Otwarte Czasopisma Naukowe UAM",
|
||||
abbrev="OtwCzasNaukUAM",
|
||||
lLevel=0,
|
||||
webpage=start}
|
||||
extractItemsStartingFromUrl shadowLibrary start (extractRecords >>> arr toShadowItem)
|
@ -19,7 +19,6 @@ library
|
||||
build-depends: base >= 4.7 && < 5
|
||||
, HTTP
|
||||
, hxt
|
||||
, hxt-curl
|
||||
, hxt-http
|
||||
, hxt-xpath
|
||||
, MissingH
|
||||
@ -28,7 +27,6 @@ library
|
||||
, network-uri
|
||||
, regex-pcre
|
||||
, regex-tdfa
|
||||
, regex-tdfa-text
|
||||
, resourcet
|
||||
, text
|
||||
, time
|
||||
@ -61,20 +59,6 @@ executable almanachmuszyny
|
||||
, shadow-library
|
||||
default-language: Haskell2010
|
||||
|
||||
executable otwarteczasopismauam
|
||||
hs-source-dirs: app
|
||||
main-is: otwarteczasopismauam.hs
|
||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends: base
|
||||
, hxt
|
||||
, hxt-xpath
|
||||
, hxt-curl
|
||||
, MissingH
|
||||
, regex-posix
|
||||
, regex-tdfa
|
||||
, regex-tdfa-text
|
||||
, shadow-library
|
||||
default-language: Haskell2010
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
|
@ -1,19 +0,0 @@
|
||||
# This file was autogenerated by Stack.
|
||||
# You should not edit this file by hand.
|
||||
# For more information, please see the documentation at:
|
||||
# https://docs.haskellstack.org/en/stable/lock_files
|
||||
|
||||
packages:
|
||||
- completed:
|
||||
hackage: hxt-xpath-9.1.2.2@sha256:9cd590ae93a04573db8f90fa4094625ebd97dded45da7667c577ce6b38a42900,1999
|
||||
pantry-tree:
|
||||
size: 2225
|
||||
sha256: aee2f75974e868ff429b8ff349a29667536c60397098f5dfedc968d1951511bb
|
||||
original:
|
||||
hackage: hxt-xpath-9.1.2.2
|
||||
snapshots:
|
||||
- completed:
|
||||
size: 507596
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/11/9.yaml
|
||||
sha256: 42f472dbf06482da1b3319241f3e3b3593a45bd7d4f537d2789f21386b9b2ad3
|
||||
original: lts-11.9
|
Loading…
Reference in New Issue
Block a user