Skip to content

Instantly share code, notes, and snippets.

@ad-m
Created August 30, 2021 13:59
Show Gist options
  • Save ad-m/2a1fff87a605cedfa4bb9323f8dddbd1 to your computer and use it in GitHub Desktop.
Save ad-m/2a1fff87a605cedfa4bb9323f8dddbd1 to your computer and use it in GitHub Desktop.
Widok.gov.pl - eksport danych
{
"dependencies": {
"superagent": "^6.1.0"
}
}
'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