Skip to content

Instantly share code, notes, and snippets.

@DavideMontersino
Created May 22, 2018 09:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavideMontersino/9a8259ccf829a451da26230112f6913e to your computer and use it in GitHub Desktop.
Save DavideMontersino/9a8259ccf829a451da26230112f6913e to your computer and use it in GitHub Desktop.
ING bankieren afschrift creditcard downloaden
// AT Ing, they say they cannot let you download an extract of your
// credit card expenses because it is impossible given how the system was built.
// But I needed to be able to do it, so I just spent an hour doing it.
function ConvertToCSV(objArray) {
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
var str = '';
for (var i = 0; i < array.length; i++) {
var line = '';
for (var index in array[i]) {
if (line != '') line += ','
line += array[i][index];
}
str += line + '\r\n';
}
return str;
}
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
var arr = [];
$('tr.riaf-datatable-contents').trigger('click');
$('tr.riaf-datatable-contents').each(function(index) {
var vreemdeValuta = $(this).next().find('td.riaf-datatable-details-contents>table>tbody>tr:nth-child(3)>td:nth-child(2)').text();
var datum = $(this).find('td.riaf-datatable-column-date').text();
var partsOfDate = datum.split("-");
var currentLine = {
datum: new Date(Number(partsOfDate[2]), Number(partsOfDate[1]) - 1, Number(partsOfDate[0])),
amount: $(this).find('td.riaf-datatable-column-amount').text().replace(',','.'),
description: $(this).find('td.riaf-datatable-column-text').text(),
};
if (vreemdeValuta){
originValueMatch = vreemdeValuta.match(/[0-9]+,[0-9]{2}/);
originCurrencyMatch = vreemdeValuta.match(/^[A-Z]+/);
if (originValueMatch && originCurrencyMatch){
currentLine.originalValue = originValueMatch ? originValueMatch[0].replace(',','.') : '';
currentLine.originCurrency = originCurrencyMatch[0] || '';
} else {
console.log({
originValueMatch, originCurrencyMatch, vreemdeValuta
})
}
}
arr.push(currentLine);
});
console.log(arr);
download('extract.csv', ConvertToCSV(arr));
@antonyantony
Copy link

antonyantony commented Dec 17, 2018

This script looks like exactly what I need. However, I got an error. May be their page changed?
Is there a newer version? thanks.

/*
Exception: TypeError: $(...) is null
@Scratchpad/4:37:1
*/

current page seems to iterating over

  • ... ...
  • @Ev2geny
    Copy link

    Ev2geny commented Dec 26, 2022

    I have also created a Python tool IngBank2Excel, which allows to create an Excel or CSV file with all credit card transactions, available through the web interface of the ING bank

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