Skip to content

Instantly share code, notes, and snippets.

@polarnik
Created August 18, 2022 04:06
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 polarnik/125c7946a119a898c080cf8168ee15c8 to your computer and use it in GitHub Desktop.
Save polarnik/125c7946a119a898c080cf8168ee15c8 to your computer and use it in GitHub Desktop.
getmentor.ru top.mentors
let teachers = document.querySelectorAll('a[target="_blank"]');
const initialValue = [];
Array.from(teachers).reduce(
(prev, curr) => {
let divs = curr.querySelectorAll('div.mt-3');
console.log(divs.length);
if (divs.length == 1 && divs[0].children && divs[0].children.length == 5) {
console.log(divs[0].children);
const parseData = {
count: Number(divs[0].children[4].textContent.split(' ')[1]),
name: divs[0].children[0].textContent,
title: divs[0].children[1].textContent,
href: 'https://getmentor.ru' + curr.getAttribute('href')
};
if(prev) {
return prev.concat(Array.of(parseData));
} else {
Array.of(parseData);
}
} else {
return prev;
}
},
initialValue
).sort((a, b) => (a.count < b.count) ? 1 : -1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment