Skip to content

Instantly share code, notes, and snippets.

@pingec
Created February 11, 2019 11:39
Show Gist options
  • Save pingec/73878df1f603fd8ba54511f109788484 to your computer and use it in GitHub Desktop.
Save pingec/73878df1f603fd8ba54511f109788484 to your computer and use it in GitHub Desktop.
Dumps bitstamp transactions from html table to csv string (including transaction IDs)
/* Dumps bitstamp transactions from html table to csv string (including transaction IDs) */
let bitStampTrxToCsv = () => {
let trxs = $("table.transactions").find("tr");
let csv = "";
for (let i = 0; i < trxs.length - 1; i++) {
if (trxs.eq(i).is(".details")) {
continue;
}
let line = "";
trxs.eq(i).find("td").each((_, td) => {
line += `"${$(td).text()}",`;
});
if (trxs.eq(i + 1).is(".details")) {
let text = trxs.eq(i + 1).find("td").text();
line += `,"${text.split("(TXID): ")[1]}"`;
}
else {
line += ","
}
csv += line + "\r\n";
}
return csv;
}
console.log(bitStampTrxToCsv());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment