mirror of
https://github.com/ION606/linkedin-api.git
synced 2026-06-05 23:16:14 +00:00
fixed some issues with searchEmployees
This commit is contained in:
+5
-7
@@ -240,14 +240,14 @@ 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.ceil(limit / 10)) : null;
|
||||
|
||||
for (let i = 0; empAll.length < limit; i += 50) {
|
||||
for (let i = 0; empAll.length < limit; i += 20) {
|
||||
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 += '),includeFiltersInResponse:false),count:50)';
|
||||
urlExt += '),includeFiltersInResponse:false))';
|
||||
|
||||
const r = await this._makeReq(urlExt);
|
||||
|
||||
@@ -263,14 +263,12 @@ export default class linkedInAPIClass {
|
||||
else return (e.template === 'UNIVERSAL' && e.title.text !== 'LinkedIn Member');
|
||||
});
|
||||
|
||||
if (this.logAll) console.log(r.included?.length, '--->', filtered.length);
|
||||
// if (this.logAll) console.error(r.included?.length, '--->', filtered.length);
|
||||
|
||||
if (filtered.length) {
|
||||
if (this.logAll) lb.increment(Math.round(filtered.length / 10));
|
||||
if (this.logAll) lb.increment(Math.ceil(filtered.length / 10));
|
||||
empAll.push(...filtered);
|
||||
}
|
||||
|
||||
await this.evade();
|
||||
}
|
||||
|
||||
if (!castToClass) return empAll;
|
||||
|
||||
+5
-6
@@ -14,19 +14,18 @@ export class Company {
|
||||
* @note This function skips over any employees who's profile is marked as private
|
||||
*/
|
||||
async getEmployees(limit = Infinity, raw = false) {
|
||||
const employeesInit = await this.#APIRef._makeReq(`variables=(start:0,origin:FACETED_SEARCH,query:(flagshipSearchIntent:ORGANIZATIONS_PEOPLE_ALUMNI,queryParameters:List((key:currentCompany,value:List(${this.urn})),(key:resultType,value:List(ORGANIZATION_ALUMNI))),includeFiltersInResponse:true),count:1)`)
|
||||
const employeesInit = await this.#APIRef._makeReq(`variables=(start:0,origin:FACETED_SEARCH,query:(flagshipSearchIntent:ORGANIZATIONS_PEOPLE_ALUMNI,queryParameters:List((key:currentCompany,value:List(${this.entityNum})),(key:resultType,value:List(ORGANIZATION_ALUMNI))),includeFiltersInResponse:true),count:1)`);
|
||||
|
||||
const numEmp = employeesInit.data.data.searchDashClustersByAll.paging.total,
|
||||
empAll = []
|
||||
|
||||
empAll = [];
|
||||
|
||||
// since the max cap is 50, we need to iterate until it's over 50
|
||||
for (let i = 0; i < numEmp; i += 50) {
|
||||
if (empAll.length >= limit) break;
|
||||
if (empAll.length >= limit || i >= numEmp) break;
|
||||
|
||||
const c = (i + 50 >= limit) ? limit - i : 50;
|
||||
const c = (i + 50 >= numEmp) ? numEmp - i : 50;
|
||||
|
||||
const employeeRes = await this.#APIRef._makeReq(`variables=(start:${i},origin:FACETED_SEARCH,query:(flagshipSearchIntent:ORGANIZATIONS_PEOPLE_ALUMNI,queryParameters:List((key:currentCompany,value:List(${this.urn})),(key:resultType,value:List(ORGANIZATION_ALUMNI))),includeFiltersInResponse:true),count:${c})`);
|
||||
const employeeRes = await this.#APIRef._makeReq(`variables=(start:${i},origin:FACETED_SEARCH,query:(flagshipSearchIntent:ORGANIZATIONS_PEOPLE_ALUMNI,queryParameters:List((key:currentCompany,value:List(${this.entityNum})),(key:resultType,value:List(ORGANIZATION_ALUMNI))),includeFiltersInResponse:true),count:${c})`);
|
||||
const employees = employeeRes.included;
|
||||
|
||||
const empParsed = employees.filter(e => (e.$type === "com.linkedin.voyager.dash.search.EntityResultViewModel"))
|
||||
|
||||
Reference in New Issue
Block a user