mirror of
https://github.com/ION606/linkedin-api.git
synced 2026-05-15 06:16:54 +00:00
added the 'limits' param for company search
This commit is contained in:
+14
-5
@@ -190,28 +190,37 @@ export default class linkedInAPIClass {
|
|||||||
/**
|
/**
|
||||||
* @param {String} keyword i.e. "biotechnology"
|
* @param {String} keyword i.e. "biotechnology"
|
||||||
* @param {Array<Number>?} numEmp
|
* @param {Array<Number>?} numEmp
|
||||||
|
* @param {Number?} [limit=1000] the function will use the bound the given number is contained in (see {@link findRangeIndex} for ranges)
|
||||||
* @param {Number?} [start=0]
|
* @param {Number?} [start=0]
|
||||||
* @param {boolean?} [castToClass=true] whether the function should return a list of Company classes or just raw JSON
|
* @param {boolean?} [castToClass=true] whether the function should return a list of Company classes or just raw JSON
|
||||||
* @param {boolean} [excludeGeneric=false]
|
* @param {boolean} [excludeGeneric=false]
|
||||||
* @returns {Promise<[SocialActivityCounts | Group | Company | GenericEntity]>}
|
* @returns {Promise<[SocialActivityCounts | Group | Company | GenericEntity]>}
|
||||||
*/
|
*/
|
||||||
async searchCompanies(keyword, numEmp = undefined, start = 0, castToClass = true, excludeGeneric = false) {
|
async searchCompanies(keyword, numEmp = undefined, limit = 1000, start = 0, castToClass = true, excludeGeneric = false) {
|
||||||
let urlExt = `variables=(start:${start},origin:GLOBAL_SEARCH_HEADER,query:(keywords:${keyword},flagshipSearchIntent:SEARCH_SRP,queryParameters:List((key:resultType,value:List(COMPANIES))${(numEmp) ? `,(key:companySize,value:List(${numsToSizes(...numEmp)}))` : ''}),includeFiltersInResponse:false))`;
|
const compAll = [];
|
||||||
|
for (let i = start; i < limit; i += 50) {
|
||||||
|
let urlExt = `variables=(start:${i},origin:GLOBAL_SEARCH_HEADER,query:(keywords:${keyword},flagshipSearchIntent:SEARCH_SRP,queryParameters:List((key:resultType,value:List(COMPANIES))${(numEmp) ? `,(key:companySize,value:List(${numsToSizes(...numEmp)}))` : ''}),includeFiltersInResponse:false))`;
|
||||||
const r = await this._makeReq(urlExt);
|
const r = await this._makeReq(urlExt);
|
||||||
|
|
||||||
if (!r?.included && r?.data?.errors) {
|
if (!r?.included && r?.data?.errors) {
|
||||||
console.error(JSON.stringify(r.data.errors))
|
console.error(JSON.stringify(r.data.errors))
|
||||||
throw "ERROR!";
|
throw "ERROR!";
|
||||||
}
|
}
|
||||||
if (!castToClass) return r;
|
|
||||||
else return parseResponse(r, this, excludeGeneric);
|
if (!castToClass) compAll.push(r);
|
||||||
|
else compAll.push(await parseResponse(r, this, excludeGeneric));
|
||||||
|
|
||||||
|
await this.evade();
|
||||||
|
}
|
||||||
|
|
||||||
|
return compAll.flat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<LinkedInProfile[]>}
|
* @returns {Promise<LinkedInProfile[]>}
|
||||||
* @param {String} keyword the user to search for
|
* @param {String} keyword the user to search for
|
||||||
* @param {Number?} [limit=1000] the function will find the bound the given number is contained in (see {@link findRangeIndex} for ranges)
|
* @param {Number?} [limit=1000] the function will use the bound the given number is contained in (see {@link findRangeIndex} for ranges)
|
||||||
* @param {boolean?} [castToClass=true] whether the function should return a list of Company classes or just raw JSON
|
* @param {boolean?} [castToClass=true] whether the function should return a list of Company classes or just raw JSON
|
||||||
* @param {boolean} [filterObfuscated=true] where or not to filter out members with obfuscated profiles ("LinkedIn Member")
|
* @param {boolean} [filterObfuscated=true] where or not to filter out members with obfuscated profiles ("LinkedIn Member")
|
||||||
* @param {Array<String>?} currentCompanies
|
* @param {Array<String>?} currentCompanies
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"name": "linkedin-api-js",
|
"name": "linkedin-api-js",
|
||||||
"version": "1.0.0-7",
|
"version": "1.0.0-9",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import fs from 'fs';
|
|||||||
const o = JSON.parse(fs.readFileSync('config.json'));
|
const o = JSON.parse(fs.readFileSync('config.json'));
|
||||||
await LAPI.login(o.email, o.password);
|
await LAPI.login(o.email, o.password);
|
||||||
|
|
||||||
const c = await LAPI.searchCompanies('microsoft', [10, 500, 5000], 0, true, true);
|
const c = await LAPI.searchCompanies('microsoft', [10, 500, 5000], 20, 0, true, true);
|
||||||
|
|
||||||
console.log(c);
|
console.log(c);
|
||||||
|
|
||||||
const managers = await c.find(o => (o.name === 'Microsoft')).searchEmployees('manager', 5);
|
const managers = await c.find(o => (o.name === 'Microsoft')).searchEmployees('manager', 5);
|
||||||
|
|||||||
Reference in New Issue
Block a user