Created
August 30, 2021 13:59
-
-
Save ad-m/2a1fff87a605cedfa4bb9323f8dddbd1 to your computer and use it in GitHub Desktop.
Widok.gov.pl - eksport danych
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"superagent": "^6.1.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const superagent = require('superagent'); | |
const YEARS = [ | |
'2018', | |
'2019', | |
'2020', | |
'2021' | |
]; | |
const SERVICES = [ | |
'ePUAP-Pismo-ogolne-do-podmiotu-publicznego-stary-wzor', | |
'epuap-dopisanie-do-spisu-wyborcow', | |
'ePUAP-wpisanie-wyborcy-do-rejestru-wyborcow', | |
'ePUAP-Wnioskowanie-o-wydanie-odpisu-aktu-stanu-cywilnego', | |
'epuap-odpis-rejestru-stanu-cywilnego', | |
'epuap-upl-1', | |
'epuap-ord-in', | |
]; | |
const main = async () => { | |
for (const service of SERVICES) { | |
for (const year of YEARS) { | |
const resp = await superagent | |
.get(`https://widok.gov.pl/services/${service}/?type=data_graph&year=${year}`) | |
.disableTLSCerts() | |
.set({ | |
'X-Requested-With': 'XMLHttpRequest', | |
}); | |
const labels = resp.body.labels; | |
const values = [ | |
resp.body.transaction_data[0], | |
...resp.body.transaction_data.slice(1).map((x, index) => x - resp.body.transaction_data[index]) | |
]; | |
for(const index of values.keys()){ | |
console.log(`${service};${year};${index+1};${labels[index]};${values[index]}`); | |
} | |
} | |
} | |
} | |
main().catch(err => { | |
console.error(err); | |
process.exit(-1); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment