member count scraping fix

This commit is contained in:
2024-05-13 15:21:06 -07:00
parent 2296d13654
commit ae600c4544
4 changed files with 14 additions and 10 deletions
+1 -1
View File
@@ -129,6 +129,6 @@ dist
.yarn/install-state.gz
.pnp.*
temp.js
temp.*
config.json
cookie.txt
+10 -6
View File
@@ -240,18 +240,16 @@ export default class linkedInAPIClass {
*/
async searchEmployees(keyword, limit = 1000, castToClass = true, filterObfuscated = true, currentCompanies = [], conDeg = []) {
const empAll = [],
lb = (this.logAll) ? new LoadingBar(Math.floor(limit/10)) : null;
lb = (this.logAll) ? new LoadingBar(Math.floor(limit / 10)) : null;
for (let i = 0; empAll.length < limit; i += 50) {
let urlExt = `includeWebMetadata=true&variables=(start:${i},query:(keywords:${keyword},flagshipSearchIntent:SEARCH_SRP,queryParameters:List((key:resultType,value:List(PEOPLE))`;
let urlExt = `includeWebMetadata=true&variables=(start:${i},origin:FACETED_SEARCH,query:(keywords:${keyword},flagshipSearchIntent:SEARCH_SRP,queryParameters:List((key:resultType,value:List(PEOPLE))`;
if (currentCompanies.length) urlExt += `,(key:currentCompany,value:List(${currentCompanies.join(',')}))`;
if (conDeg.length) urlExt += `,(key:network,value:List(${numToConDegs(conDeg)}))`;
urlExt += ')))';
urlExt += '),includeFiltersInResponse:false),count:50)';
const r = await this._makeReq(urlExt);
if (this.logAll) lb.increment(5);
// there's nothing left, returns what we have
if (!r?.included?.length) {
@@ -265,7 +263,13 @@ export default class linkedInAPIClass {
else return (e.template === 'UNIVERSAL' && e.title.text !== 'LinkedIn Member');
});
if (filtered.length) empAll.push(...filtered);
if (this.logAll) console.log(r.included?.length, '--->', filtered.length);
if (filtered.length) {
if (this.logAll) lb.increment(Math.round(filtered.length / 10));
empAll.push(...filtered);
}
await this.evade();
}
+1 -1
View File
@@ -8,7 +8,7 @@
},
"type": "module",
"name": "linkedin-api-js",
"version": "1.0.0-11",
"version": "1.0.0-13",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
+2 -2
View File
@@ -7,9 +7,9 @@ import fs from 'fs';
const o = JSON.parse(fs.readFileSync('config.json'));
await LAPI.login(o.email, o.password);
const c = await LAPI.searchCompanies('microsoft', [5001], 20, 0, true, true);
const c = (await LAPI.searchCompanies('microsoft', [5001], 20, 0, true, true)).find(o => (o.name === 'Microsoft'));
console.log(c);
const managers = await c.find(o => (o.name === 'Microsoft')).searchEmployees('manager', 5);
const managers = await c.searchEmployees('manager');
console.log(managers, managers.length);
})();