Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
www.sgxdata.pebbleslab.com scrape table to csv eg. for Excel
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