Skip to content

Instantly share code, notes, and snippets.

@richjenks
Created April 12, 2019 11:41
Show Gist options
  • Save richjenks/6b01f92d95c46d2ba543851a85729c04 to your computer and use it in GitHub Desktop.
Save richjenks/6b01f92d95c46d2ba543851a85729c04 to your computer and use it in GitHub Desktop.
Webpage Data to TSV

Webpage Data to TSV

Copy data from a webpage to your clipboard so it's ready to be pasted into a spreadsheet.

For example, say there are a list of links on a page and you want to get the ID, link text, and href.

All we're doing is iterating through each item, constructing a series of tab-separated value rows and copying it to the clipboard.

Make sure each item is separated with a tab and each row is terminated with a newline.

var tsv = ''
document.querySelectorAll('.css-selector-to-grab-elements').forEach(function(item) {
tsv += item.id + '\t' + item.innerText + '\t' + item.href + '\n'
})
copy(tsv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment