Created
April 16, 2019 16:44
-
-
Save lathropd/d7350765dbbc5552b865eba696d7376d to your computer and use it in GitHub Desktop.
x-ray scraper for maryland mens basketball
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
let Xray = require('x-ray') | |
let x = Xray() | |
x('https://umterps.com/schedule.aspx?schedule=365', '.hide-on-medium-only .sidearm-schedule-game-links-boxscore', [{ | |
url: 'a@href', | |
game: x('a@href', { | |
date: '.game-details dl dd', | |
time: '.game-details dl dd:nth-of-type(2)', | |
attendance: '.game-details dl dd:nth-of-type(3)', | |
visitor: '.box-score-header figcaption table tbody tr th span.hide-on-small-down', | |
home: '.box-score-header figcaption table tbody tr:nth-of-type(2) th span.hide-on-small-down', | |
homeplayers: x('#box-score section table:nth-of-type(1).overall-stats tbody tr', [{ | |
number:'td', | |
name: 'th', | |
started: 'td:nth-of-type(2)' | |
}]), | |
visitingplayers: x('#box-score section:nth-of-type(2) table:nth-of-type(1).overall-stats tbody tr', [{ | |
number:'td', | |
name: 'th', | |
started: 'td:nth-of-type(2)' | |
}]), | |
pbpFirst: x('div#period-1 table tbody tr', [{ | |
time: 'th', | |
homePlay:'td', | |
homeScore: 'td:nth-of-type(2)', | |
homePlus: 'td:nth-of-type(2) span', | |
visitorPlay:'td:nth-of-type(5)', | |
visitorScore: 'td:nth-of-type(4)', | |
visitorPlus: 'td:nth-of-type(4) span', | |
}] ), | |
pbpSecond: x('div#period-2 table tbody tr', [{ | |
time: 'th', | |
homePlay:'td', | |
homeScore: 'td:nth-of-type(2)', | |
homePlus: 'td:nth-of-type(2) span', | |
visitorPlay:'td:nth-of-type(5)', | |
visitorScore: 'td:nth-of-type(4)', | |
visitorPlus: 'td:nth-of-type(4) span', | |
}] ) | |
}), | |
}] | |
).write('md.json') | |
// .then(console.log) | |
// .then( (res) => console.log(JSON.stringify(res[0]))) | |
// .then(res => console.log(res[0])){} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment