Created
August 18, 2022 04:06
-
-
Save polarnik/125c7946a119a898c080cf8168ee15c8 to your computer and use it in GitHub Desktop.
getmentor.ru top.mentors
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
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