Last active
April 26, 2016 16:58
-
-
Save alex-bender/3dcf09a2c6d38e4a1318 to your computer and use it in GitHub Desktop.
code for getting song list json from vk.com
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
var hiddenFields = document.getElementsByTagName("input"); | |
var mp3s = []; | |
function getHiddenField(elem, index, collection){ | |
if(elem.getAttribute("type") == "hidden" && (/audio_info\d+_\d+/).test(elem.getAttribute("id"))){ | |
mp3s.push({ | |
'artist': elem.parentElement.nextSibling.nextSibling.childNodes[1].childNodes[0].textContent, | |
'title': elem.parentElement.nextSibling.nextSibling.childNodes[1].childNodes[2].textContent, | |
'url': elem.getAttribute("value").split(",")[0].split('?')[0] | |
}); | |
} | |
} | |
for(var i=0; i < hiddenFields.length; i++){ | |
getHiddenField(hiddenFields[i], i, hiddenFields); | |
} | |
console.log(JSON.stringify(mp3s)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment