Skip to content

Instantly share code, notes, and snippets.

@Rillke
Created November 11, 2019 15:27
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 Rillke/9cefde955c0eddf61909ea6183f2c5b0 to your computer and use it in GitHub Desktop.
Save Rillke/9cefde955c0eddf61909ea6183f2c5b0 to your computer and use it in GitHub Desktop.
Extract data from N°26 bank transactions page
let balance = 0;
let transactions = [];
for (elem of document.querySelectorAll('a[href^="/transactions"]')) {
console.log(Array(20).join('-'));
const parent = elem.parentNode;
if (!parent) {
console.warn('skip [parent]', elem, elem.innerText);
continue;
}
const amountNode = parent.nextSibling;
if (!amountNode) {
console.warn('skip [sibling]', elem, elem.innerText);
continue;
}
const amountText = amountNode.innerText;
if (amountText.indexOf('My Account') !== -1) {
console.warn('skip [balance]', elem, elem.innerText);
continue;
}
const cleanAmountText = amountText
.replace(/.*\r?\n?[^−]*(−?€\d+\.\d+).*/, '$1')
.replace('−', '-')
.replace('€', '');
const amount = parseFloat(cleanAmountText);
if (isNaN(amount)) {
console.warn('skip [NaN]', amountText, cleanAmountText, elem, elem.innerText);
continue;
}
const subject = elem.innerText;
transactions.push( { subject: subject, amount: amount } );
balance += amount;
}
console.log('TOTAL BALANCE: ' + balance);
console.log(JSON.stringify(transactions));
@Rillke
Copy link
Author

Rillke commented Nov 11, 2019

Suspect irregularities about your N°26 account balance? That's why I created this script.
Note that all data must be loaded before executing this script and the script uses floats for calculation so expect some minor difference to the actual amount. No warranty is provided.

@Rillke
Copy link
Author

Rillke commented Nov 11, 2019

Note that under downloads there is the possibility to export CSV and PDF, but these may not include the newest transactions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment