Created
April 14, 2015 15:50
-
-
Save rctay/d4c1e97aee49c5e2e946 to your computer and use it in GitHub Desktop.
www.sgxdata.pebbleslab.com scrape table to csv eg. for Excel
This file contains 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
var rows_all = document.getElementsByTagName("table")[4].children[0].children | |
var rows = Array.prototype.slice.call(rows_all, 2) | |
var rows_data = rows.map(function(row) { return Array.prototype.map.call(row.children, function(c, i) { var v = c.innerText; return i===2 ? v.replace("\n"," ") : v }) }) | |
// poor man's csv - doesn't handle values with the delimiter itself! | |
console.log(rows_data.map(function(c) { return c.join(",") }).join("\n")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment