Created
January 10, 2019 13:22
-
-
Save oresh/9eba509bc2bfe159edec7ef1549e5d1f to your computer and use it in GitHub Desktop.
Scrape companies from Linkedin
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
// 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