Skip to content

Instantly share code, notes, and snippets.

@jaseclamp
Last active August 29, 2019 07:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jaseclamp/b67e0b521b55b5e2a5580e1ad7707450 to your computer and use it in GitHub Desktop.
Save jaseclamp/b67e0b521b55b5e2a5580e1ad7707450 to your computer and use it in GitHub Desktop.
meetup linkedin search
/*
INSTRUCTIONS
1. Open this file in notepad or something similar
2. Paste your list of names where it says replace names
3. Go to linkedin and line up a people search for your city
4. In google chrome. In Windows and Linux hit: Ctrl + Shift + J. On Mac hit: Cmd + Option + J.
5. Copy paste this whole script in to the console and hit enter
6. leave the window active while it collects results
7. You should get a tab seperated CSV that you can open in Excel
*/
//REPLACE THE NAMES ONLY
var input = `
first last
bob evans
steve smith
`;
var names = input.trim().split('\n');
var people = [];
var i = 0;
function loop() {
//because I'm from the past and don't know about setting up promises and waiting for them to complete
setTimeout( function() {
console.log( 'run number ' + i );
if (i > 0) {
var j = i - 1;
people[j] = {};
var firstEntry = jQuery('li.search-result div.search-result--person').first();
if( firstEntry.length > 0 )
{
people[j].name = firstEntry.find('span.actor-name').text().trim();
people[j].link = firstEntry.find('a').prop('href').trim();
people[j].des = firstEntry.find('p.subline-level-1').text().replace(/[\n\r]+/g, '').trim();
people[j].loc = firstEntry.find('p.subline-level-2').text().replace(/[\n\r]+/g, '').trim();
people[j].pos = firstEntry.find('p.mt2').text().replace(/[\n\r]+/g, '').trim();
console.log( 'stored ' + people[j].name );
}else{
people[j].name = names[j];
people[j].link = 'not found';
people[j].des = 'not found';
people[j].loc = 'not found';
people[j].pos = 'not found';
}
}
if( i < names.length ) {
$('div#global-nav-typeahead')[0].dispatchEvent(new Event('focus'));
$('div#global-nav-typeahead input')[0].value = names[i];
$('div#global-nav-typeahead input')[0].dispatchEvent(new Event('input'));
Ember.run(() => {
var blerg = $.Event('keydown');
blerg.which = 13;
blerg.keyCode = 13;
this.$('form#extended-nav-search input').focus();
this.$('form#extended-nav-search input').trigger(blerg);
});
i++;
loop();
}
else wrapup(people);
}, 3000);
}
function wrapup(people)
{
console.log(people);
var tsv = tabValues(people);
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(tsv);
hiddenElement.target = '_blank';
hiddenElement.download = 'people.csv';
hiddenElement.click();
}
function tabValues(array) {
var keys = Object.keys(array[0]);
var result = keys.join("\t") + "\n";
array.forEach(function(obj){
keys.forEach(function(k, ix){
if (ix) result += "\t";
result += obj[k];
});
result += "\n";
});
return result;
}
/////////////////////kick it off
loop();
@rvvvt
Copy link

rvvvt commented Aug 29, 2019

flawless

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment