Skip to content

Instantly share code, notes, and snippets.

@swingley
Created January 21, 2016 06:46
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 swingley/6ea61dce24a2937798c8 to your computer and use it in GitHub Desktop.
Save swingley/6ea61dce24a2937798c8 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const Xray = require('x-ray');
const xray = new Xray();
const table = 'score-table.html';
const out = 'scores.json';
fs.readFile(table, (err, data) => {
// Pull data out of the table.
// Team names are td elements with .team.
// Scores are td elements with .stat.
// Need to grab the dropped week too.
// Total score has .total and .current.
xray(data, 'tbody tr', [{
name: 'td.team',
scores: xray(['td.stat']),
dropped: 'td.dropped-pts',
total: 'td.total.current'
}])((err, data) => {
fs.writeFile(out, JSON.stringify(data, null, 2));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment