forked from filipg/twilight-library
Compare commits
No commits in common. "master" and "master" have entirely different histories.
@ -1,7 +0,0 @@
|
|||||||
# Strona
|
|
||||||
Strona: https://bip.um.gdynia.pl/wyszukiwarka-uchwal-rady-miasta,7485/wyszukiwarka-uchwal,504923
|
|
||||||
|
|
||||||
|
|
||||||
# Wyniki
|
|
||||||
Lata 1990 - 1999 -> oldFiles.json \
|
|
||||||
Lata 2000 - 2022 -> newFiles.json
|
|
71
app/test.hs
71
app/test.hs
@ -1,71 +0,0 @@
|
|||||||
|
|
||||||
{-# LANGUAGE Arrows, NoMonomorphismRestriction #-}
|
|
||||||
import ShadowLibrary.Core
|
|
||||||
|
|
||||||
import Text.XML.HXT.Core
|
|
||||||
import Text.XML.HXT.XPath
|
|
||||||
import Data.List
|
|
||||||
import Data.List.Utils (replace)
|
|
||||||
|
|
||||||
import Text.Regex.Posix
|
|
||||||
import Text.Printf
|
|
||||||
import System.IO
|
|
||||||
|
|
||||||
|
|
||||||
extractYears = extractLinksWithText "//div[@class='inner clearfix']//div[@class='row']//div[@class='col-sm-6']//ul//li//a" -- pary adres-tytuł
|
|
||||||
runYearsExtractor url = runX $ (arr (const url) >>> setTraceLevel 1 >>> extractYears)
|
|
||||||
|
|
||||||
extractNewFiles = extractLinksWithText "//a[@title='Pobierz plik']" -- pary adres-tytuł
|
|
||||||
runNewFilesExtractor url = runX $ (arr (const url) >>> setTraceLevel 1 >>> extractNewFiles)
|
|
||||||
|
|
||||||
extractOldFiles = extractLinksWithText "//div[@class='content']//div[@class='inner clearfix']//ul//li//a" -- pary adres-tytuł
|
|
||||||
runOldFilesExtractor url = runX $ (arr (const url) >>> setTraceLevel 1 >>> extractOldFiles)
|
|
||||||
|
|
||||||
--367-376
|
|
||||||
extractOldYears = extractLinksWithText "//nav[@class='nav-left']//ul//li[@class='single-article']/a" -- pary adres-tytuł
|
|
||||||
runOldYearsExtractor url = runX $ (arr (const url) >>> setTraceLevel 1 >>> extractOldYears)
|
|
||||||
|
|
||||||
mapToUrl :: ([Char], [Char]) -> [Char]
|
|
||||||
mapToUrl (url, title) = url
|
|
||||||
|
|
||||||
merge [] ys = ys
|
|
||||||
merge (x:xs) ys = x:merge ys xs
|
|
||||||
|
|
||||||
repeatNTimes 0 = return []
|
|
||||||
repeatNTimes n = do
|
|
||||||
let link = "https://bip.um.gdynia.pl/module/Contents/controller/Default/action/loadSubcategory/subcategory_id/" ++ show (377-n)
|
|
||||||
items <- runOldYearsExtractor link
|
|
||||||
let urls = map mapToUrl items
|
|
||||||
recursive <- repeatNTimes (n-1)
|
|
||||||
let results = merge urls recursive
|
|
||||||
return results
|
|
||||||
|
|
||||||
flatten :: [[a]] -> [a]
|
|
||||||
flatten xs = (\z n -> foldr (\x y -> foldr z y x) n xs) (:) []
|
|
||||||
|
|
||||||
getAllPages url = do
|
|
||||||
items <- runYearsExtractor url
|
|
||||||
let urls = map mapToUrl items
|
|
||||||
newFiles <- mapM runNewFilesExtractor urls
|
|
||||||
let fileUrls = map mapToUrl (flatten newFiles)
|
|
||||||
return fileUrls
|
|
||||||
|
|
||||||
getOldFiles = do
|
|
||||||
oldPages <- repeatNTimes 10
|
|
||||||
--let sub = take 2 oldPages
|
|
||||||
oldFiles <- mapM runOldFilesExtractor oldPages
|
|
||||||
let fileUrls = map mapToUrl (flatten oldFiles)
|
|
||||||
return fileUrls
|
|
||||||
|
|
||||||
main = do
|
|
||||||
let start = "https://bip.um.gdynia.pl/wyszukiwarka-uchwal-rady-miasta,7485/wyszukiwarka-uchwal,504923"
|
|
||||||
oldResults <- getOldFiles
|
|
||||||
oldF <- openFile "oldFiles.json" WriteMode
|
|
||||||
hPrint oldF oldResults
|
|
||||||
hClose oldF
|
|
||||||
|
|
||||||
--print (length results)
|
|
||||||
newResults <- getAllPages start
|
|
||||||
newF <- openFile "newFiles.json" WriteMode
|
|
||||||
hPrint newF newResults
|
|
||||||
hClose newF
|
|
@ -1 +0,0 @@
|
|||||||
[]
|
|
@ -1 +0,0 @@
|
|||||||
[]
|
|
@ -59,17 +59,6 @@ executable almanachmuszyny
|
|||||||
, shadow-library
|
, shadow-library
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
||||||
executable test
|
|
||||||
hs-source-dirs: app
|
|
||||||
main-is: test.hs
|
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
|
||||||
build-depends: base
|
|
||||||
, hxt
|
|
||||||
, hxt-xpath
|
|
||||||
, MissingH
|
|
||||||
, regex-posix
|
|
||||||
, shadow-library
|
|
||||||
default-language: Haskell2010
|
|
||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
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