Created
January 17, 2018 17:05
-
-
Save timucingelici/d22c574ae482b31d8b31f3e3bfd71948 to your computer and use it in GitHub Desktop.
Export coinmarketcap.com's historical data as JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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