Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Last active February 1, 2016 01:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelficarra/0ea173a2b4bd849a9806 to your computer and use it in GitHub Desktop.
Save michaelficarra/0ea173a2b4bd849a9806 to your computer and use it in GitHub Desktop.
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