Skip to content

Instantly share code, notes, and snippets.

@oresh
Created January 10, 2019 13:22
Show Gist options
  • Save oresh/9eba509bc2bfe159edec7ef1549e5d1f to your computer and use it in GitHub Desktop.
Save oresh/9eba509bc2bfe159edec7ef1549e5d1f to your computer and use it in GitHub Desktop.
Scrape companies from Linkedin
// Search Linkedin Companies
$ = jQuery;
var $person, text, timer;
var out = [];
var timer = setInterval(function(){
getPeople();
clickPager();
}, 2200);
var cleanText = (text) => 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 = [
cleanText($person.find('.name').length ? $person.find('.name').text() : $person.find('h3.search-result__title').text()), //searching for People OR for Companies
cleanText($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() {
if(($active = $('button.next')).length) {
$active.click();
} else {
console.log(out.join('\n'));
clearInterval(timer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment