mirror of
https://github.com/ION606/linkedin-api.git
synced 2026-05-14 22:06:54 +00:00
added fetching company website
This commit is contained in:
+4
-3
@@ -205,7 +205,7 @@ export default class linkedInAPIClass {
|
||||
|
||||
const lb = (this.logAll) ? new LoadingBar(Math.round(limit / 50)) : null;
|
||||
|
||||
for (let i = start; i < limit; i += 50) {
|
||||
for (let i = start; compAll.length < 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);
|
||||
|
||||
@@ -249,7 +249,7 @@ export default class linkedInAPIClass {
|
||||
if (conDeg.length) urlExt += `,(key:network,value:List(${numToConDegs(conDeg)}))`;
|
||||
urlExt += '),includeFiltersInResponse:false))';
|
||||
|
||||
const r = await this._makeReq(urlExt);
|
||||
const r = await this._makeReq(urlExt, false, true);
|
||||
|
||||
// there's nothing left, returns what we have
|
||||
if (!r?.included?.length) {
|
||||
@@ -281,9 +281,10 @@ export default class linkedInAPIClass {
|
||||
* @returns {Promise<Buffer | null>}
|
||||
* @throws The promise will reject on error
|
||||
*/
|
||||
async _makeReq(reqPath, isProfile = false) {
|
||||
async _makeReq(reqPath, isProfile = false, ignoreTimeoutErr = false) {
|
||||
await this.evade();
|
||||
const res = await axios.get(`https://www.linkedin.com/voyager/api/graphql?${reqPath}&queryId=${(!isProfile) ? "voyagerSearchDashClusters.f0c4f21d8a526c4a5dd0ae253c9b6e02" : "voyagerIdentityDashProfiles.5a6722404e6afd08958f5105e51cad51"}`, { headers: this.headers }).catch((err) => {
|
||||
if (err?.code === 'ECONNRESET' && ignoreTimeoutErr) return null;
|
||||
console.error(err);
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import axios from "axios";
|
||||
import * as cheerio from 'cheerio';
|
||||
import linkedInAPIClass from "../index.js";
|
||||
import { LinkedInProfile } from "./Profile.js";
|
||||
|
||||
@@ -78,6 +80,12 @@ export class Company {
|
||||
this.url = data.navigationUrl;
|
||||
this.entityNum = data.trackingUrn.replace('urn:li:company:', '');
|
||||
|
||||
axios.get(this.url).then(r => {
|
||||
const $ = cheerio.load(r.data);
|
||||
const u = $('a[aria-describedby="websiteLinkDescription"]')?.attr('href')?.split('url=http')?.at(1)?.split('&')[0];
|
||||
if (u) this.websiteurl = `http${decodeURIComponent(u)}`;
|
||||
}).catch(_ => null);
|
||||
|
||||
if (!this.checkIfCompleted()) throw "NOT ALL NEEDED PARAMS FOUND!";
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@ export class LinkedInProfile {
|
||||
let { phoneNumbers, emailAddress, websites, weChatContactInfo, twitterHandles, instantMessengers } = uObj;
|
||||
|
||||
if (websites) websites = websites.map(w => ({ label: w.label, category: w.category, url: w.url }));
|
||||
return { phoneNumbers, emailAddress, websites, weChatContactInfo, twitterHandles, instantMessengers };
|
||||
return { phoneNumbers, emailAddress: (emailAddress?.emailAddress || emailAddress), websites, weChatContactInfo, twitterHandles, instantMessengers };
|
||||
}
|
||||
|
||||
// Parse specific services offered, contained in the 'simpleInsight' section of 'insightsResolutionResults'
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"type": "module",
|
||||
"name": "linkedin-api-js",
|
||||
"version": "1.0.0-19",
|
||||
"version": "1.0.0-20",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
Reference in New Issue
Block a user