Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Last active Feb 1, 2016
Embed
What would you like to do?
Rotten Tomatoes ratings exfiltrator
console.log(JSON.stringify([].map.call(document.querySelectorAll('.content_body .media-body'), function(ratingEl){
return {
title: ratingEl.childNodes[3].childNodes[1].textContent,
year: parseInt(ratingEl.childNodes[3].childNodes[2].textContent.slice(1, -1), 10),
rt_link: ratingEl.childNodes[3].childNodes[1].href,
rating: 20 * ratingEl.childNodes[5].querySelectorAll('.glyphicon-star').length + (/½/.test(ratingEl.childNodes[5].textContent) ? 10 : 0),
};
}).sort(function(a, b){ return a.title > b.title ? 1 : -1; })));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment