Created
April 1, 2018 20:24
-
-
Save copperwall/edc94910c49f67683b0d3f8a4ecbb3c0 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 fetch = require('node-fetch'); | |
const cheerio = require('cheerio'); | |
function getPlayerStats(battletag, region, platform) { | |
battletag = battletag.replace('#', '-'); | |
const url = `https://playoverwatch.com/${region}/career/${platform}/${battletag}`; | |
return fetch(url).then(response => response.text()) | |
.then(doc => { | |
const $ = cheerio.load(doc); | |
return { | |
hero: $('.header-masthead').text(), | |
games_won: $(".masthead-detail span").text().match(/\d+/) | |
}; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment