Skip to content

Instantly share code, notes, and snippets.

@shershen08
Created January 22, 2015 20:59
Show Gist options
  • Save shershen08/edab3da7a932f6f94741 to your computer and use it in GitHub Desktop.
Save shershen08/edab3da7a932f6f94741 to your computer and use it in GitHub Desktop.
console parsing of page Книжный топ–лист D3
//for page https://library.d3.ru/comments/613787/
var allNodes = document.querySelectorAll('.c_body b'), result = [];
function getBooksWithRating(item,i) {
var newItem = {}, rate;
newItem.text = item.innerHTML;
rate = item.parentNode.parentNode.querySelectorAll('.vote_result')[0] ? item.parentNode.parentNode.querySelectorAll('.vote_result')[0].innerHTML : 0;
newItem.rating = rate;
if(rate > 30){
result.push(newItem);
}
}
Array.prototype.forEach.call(allNodes, getBooksWithRating);
console.info(result.length);
copy(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment