Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Returns player stats.
- *
- * @param {string} url The url
- * @return {array} stats about the player.
- * @customfunction
- */
- function FBREF(url ) {
- const request = UrlFetchApp.fetch(url)
- const html = request.getContentText()
- const rows = html.split("</tr>").slice(-13);
- const results = [['Date', 'Started', 'Shots total', 'Shots on target', 'Tackless']]
- rows.forEach((row) => {
- try {
- const date = /date[\s\S]*?href[\s\S]*?>(.*?)</gmsi.exec(row)[1]
- const started = /game_started[\s\S]*?>(.*?)</gmsi.exec(row)[1]
- const shotsTotal = Number(/shots_total[\s\S]*?>(.*?)</gmsi.exec(row)[1])
- const shotsOnTarget = Number(/shots_on_target[\s\S]*?>(.*?)</gmsi.exec(row)[1])
- const tackles = Number(/tackles[\s\S]*?>(.*?)</gmsi.exec(row)[1])
- results.push([date, started, shotsTotal, shotsOnTarget, tackles])
- } catch (err) {}
- });
- return results
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement