Skip to content

Instantly share code, notes, and snippets.

@cincodenada
Last active Mar 13, 2016
Embed
What would you like to do?
Pulls arbitrary table data out into a TSV
trs = document.querySelectorAll('tr');
Array.prototype.map.call(trs, function(tr) {
if(tr.children.length > 2) {
return Array.prototype.map.call(tr.children, function(td) {
return td.textContent.trim();
}).join("\t");
} else {
return null;
}
}).join("\n");
// As one line
Array.prototype.map.call(document.querySelectorAll('tr'), function(tr) { if(tr.children.length > 2) { return Array.prototype.map.call(tr.children, function(td) { return td.textContent.trim(); }).join("\t")} else { return null; } }).join("\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment