Skip to content

Instantly share code, notes, and snippets.

@DmitryMyadzelets
Created November 13, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DmitryMyadzelets/0e20288a3cbd96e9284a2bad6efa29c9 to your computer and use it in GitHub Desktop.
Save DmitryMyadzelets/0e20288a3cbd96e9284a2bad6efa29c9 to your computer and use it in GitHub Desktop.
Extract data from HERA's web site
// 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