Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Export coinmarketcap.com's historical data as JSON
data = [];
headers = [];
table = $('#historical-data').find('table');
headers = table.find('th').map(function(index, item){
return $(item).text();
});
table.children('tbody').find('tr').each(function(index, item){
var row = $(item);
var obj = {};
row.find('td').each(function(cellIndex, cell){
obj[headers[cellIndex]] = $(cell).text();
});
data[index] = obj;
});
console.log(JSON.stringify(data));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment