Skip to content

Instantly share code, notes, and snippets.

@copperwall
Created April 1, 2018 20:24
Show Gist options
  • Save copperwall/edc94910c49f67683b0d3f8a4ecbb3c0 to your computer and use it in GitHub Desktop.
Save copperwall/edc94910c49f67683b0d3f8a4ecbb3c0 to your computer and use it in GitHub Desktop.
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