Skip to content

Instantly share code, notes, and snippets.

@oresh
Last active July 9, 2019 18:45
Show Gist options
  • Save oresh/f2ea5748308ec82935a68b8d62254808 to your computer and use it in GitHub Desktop.
Save oresh/f2ea5748308ec82935a68b8d62254808 to your computer and use it in GitHub Desktop.
Gather people data from search results.
$ = jQuery;
var $person, $next, text, timer;
var next_text = '';
var out = [];
var timer = setInterval(function(){
getPeople();
clickPager();
}, 5500);
var clear = function(text) {
return text.trim().replace('\n','');
}
var getPeople = function() {
var $people = $('.search-result__info');
for (var i = 0, len = $people.length; i < len; i++) {
$person = $people.eq(i);
text = [
clear($person.find('h3 .name-and-icon .name').text()),
clear($person.find('.subline-level-1').text()),
'https://www.linkedin.com' + $person.find('.search-result__result-link').attr('href')
].join(';');
out.push(text);
}
}
var clickPager = function() {
$active = $('.page-list').find('li.active');
if (!$active.is(':last-child') && $active.length) {
if (parseInt(next_text) == parseInt($active.text()) || next_text == '') {
$next = $active.next();
next_text = $next.text();
added = out.length + 10;
console.log('opening page ' + next_text + ' | added ' + added + ' people');
$next.find('button').click();
}
} else {
clearInterval(timer);
console.log('End of account pager cap or no more pages');
console.log('—.—.—.—.—.—.—');
console.log(out.join('\n'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment