Created
November 13, 2020 10:38
-
-
Save DmitryMyadzelets/0e20288a3cbd96e9284a2bad6efa29c9 to your computer and use it in GitHub Desktop.
Extract data from HERA's web site
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
// Extract price and data from your bills from HERA at https://servizionline.gruppohera.it | |
// Run it in the console on a web page with the list of bills. | |
// Created: 13/11/2020 | |
// Author: Dmitry Myadzelets | |
// | |
(function bollette () { | |
const number = /[-]{0,1}[\d]+/g | |
const row2object = tr => ({ | |
euro: Number(tr.querySelector('.importo').querySelector('span').innerText.match(number).join('.')), | |
date: tr.querySelector('.emessa').querySelector('span').innerText | |
}) | |
const rows = document.querySelector('.elenco-bollette').querySelectorAll('tr') | |
const data = Array.from(rows).map(row2object) | |
return data | |
// One year | |
//.slice(-12) | |
.slice(12) | |
// Total | |
.reduce((sum, o) => sum += o.euro, 0) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment