Skip to content

Instantly share code, notes, and snippets.

@cincodenada
Last active March 13, 2016 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cincodenada/19160fc8a18e430265db to your computer and use it in GitHub Desktop.
Save cincodenada/19160fc8a18e430265db to your computer and use it in GitHub Desktop.
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