Skip to content

Instantly share code, notes, and snippets.

@danielwatson6
Created August 7, 2017 00:30
Show Gist options
  • Save danielwatson6/283c18f526d0163c38f939b2aaf36a60 to your computer and use it in GitHub Desktop.
Save danielwatson6/283c18f526d0163c38f939b2aaf36a60 to your computer and use it in GitHub Desktop.
// Copy paste this into the JS console of any window that has loaded
// https://coinmarketcap.com/
var CURRENCY = 'bitcoin';
var w = window.open('https://coinmarketcap.com/currencies/' + CURRENCY + '/historical-data/?start=20000101&end=20170806');
w.addEventListener('load', function () {
var rows = $(w.document.getElementById('historical-data')).find('tr');
var data = [];
for (var i = 1; i < rows.length; i++) {
var items = $.map($(rows[i]).find('td'), function (td) {
return td.innerText;
});
data.push({
date: (new Date(items[0])).getTime(),
open: items[1],
high: items[2],
low: items[3],
close: items[4]
});
}
w.document.write(JSON.stringify(data))
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment