diff --git a/.gitignore b/.gitignore index ba8b951..a022392 100644 --- a/.gitignore +++ b/.gitignore @@ -129,6 +129,6 @@ dist .yarn/install-state.gz .pnp.* -temp.js +temp.* config.json cookie.txt diff --git a/classes/API.js b/classes/API.js index e6c6030..20a4387 100644 --- a/classes/API.js +++ b/classes/API.js @@ -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(); } diff --git a/package.json b/package.json index 6a0761f..3aabcb3 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/tests/companyTests.js b/tests/companyTests.js index ab09ae4..d603360 100644 --- a/tests/companyTests.js +++ b/tests/companyTests.js @@ -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); })(); \ No newline at end of file