Created
November 25, 2017 12:02
-
-
Save ChristianGaertner/8ffc2a5194268c43cf1c90b829eb744d to your computer and use it in GitHub Desktop.
last.fm currently playing track
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 username = 'lastfm_username'; | |
fetch(`https://cors-anywhere.herokuapp.com/https://www.last.fm/user/${username}`).then(r => r.text()).then(html => { | |
const parser = new DOMParser(); | |
const doc = parser.parseFromString(html, "text/html"); | |
const name = doc.querySelector('.now-scrobbling .chartlist-name > span > a').innerHTML; | |
const artist = doc.querySelector('.now-scrobbling .chartlist-name .chartlist-artists a').innerHTML; | |
return [name, artist]; | |
}).then(console.log.bind(console)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment