mirror of
https://github.com/ION606/linkedin-api.git
synced 2026-05-14 22:06:54 +00:00
member count scraping fix
This commit is contained in:
+1
-1
@@ -129,6 +129,6 @@ dist
|
|||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
temp.js
|
temp.*
|
||||||
config.json
|
config.json
|
||||||
cookie.txt
|
cookie.txt
|
||||||
|
|||||||
+10
-6
@@ -240,18 +240,16 @@ export default class linkedInAPIClass {
|
|||||||
*/
|
*/
|
||||||
async searchEmployees(keyword, limit = 1000, castToClass = true, filterObfuscated = true, currentCompanies = [], conDeg = []) {
|
async searchEmployees(keyword, limit = 1000, castToClass = true, filterObfuscated = true, currentCompanies = [], conDeg = []) {
|
||||||
const empAll = [],
|
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) {
|
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 (currentCompanies.length) urlExt += `,(key:currentCompany,value:List(${currentCompanies.join(',')}))`;
|
||||||
if (conDeg.length) urlExt += `,(key:network,value:List(${numToConDegs(conDeg)}))`;
|
if (conDeg.length) urlExt += `,(key:network,value:List(${numToConDegs(conDeg)}))`;
|
||||||
urlExt += ')))';
|
urlExt += '),includeFiltersInResponse:false),count:50)';
|
||||||
|
|
||||||
const r = await this._makeReq(urlExt);
|
const r = await this._makeReq(urlExt);
|
||||||
|
|
||||||
if (this.logAll) lb.increment(5);
|
|
||||||
|
|
||||||
// there's nothing left, returns what we have
|
// there's nothing left, returns what we have
|
||||||
if (!r?.included?.length) {
|
if (!r?.included?.length) {
|
||||||
@@ -265,7 +263,13 @@ export default class linkedInAPIClass {
|
|||||||
else return (e.template === 'UNIVERSAL' && e.title.text !== 'LinkedIn Member');
|
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();
|
await this.evade();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"name": "linkedin-api-js",
|
"name": "linkedin-api-js",
|
||||||
"version": "1.0.0-11",
|
"version": "1.0.0-13",
|
||||||
"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,9 +7,9 @@ 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', [5001], 20, 0, true, true);
|
const c = (await LAPI.searchCompanies('microsoft', [5001], 20, 0, true, true)).find(o => (o.name === 'Microsoft'));
|
||||||
console.log(c);
|
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);
|
console.log(managers, managers.length);
|
||||||
})();
|
})();
|
||||||
Reference in New Issue
Block a user