Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save timucingelici/d22c574ae482b31d8b31f3e3bfd71948 to your computer and use it in GitHub Desktop.
Save timucingelici/d22c574ae482b31d8b31f3e3bfd71948 to your computer and use it in GitHub Desktop.
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