Skip to content

Instantly share code, notes, and snippets.

@janjongboom
Last active December 23, 2015 06:18
Show Gist options
  • Save janjongboom/6592628 to your computer and use it in GitHub Desktop.
Save janjongboom/6592628 to your computer and use it in GitHub Desktop.
jQuery scraping examples
// https://mdn.mozillademos.org/en-US/docs/Web/HTML/Element/table$samples/Examples?revision=446977
var t = $('table:nth(1)')
var keys = [].slice.call(t.find('tr:nth(0) th').map(function() { return $(this).text() }))
t.find('tr:gt(0)').map(function(tix, el) {
return keys.reduce(function(obj, k, ix) { return obj[k] = $(el).find('td:nth(' + ix + ')').text(), obj }, {})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment