-
-
Save swingley/6ea61dce24a2937798c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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