mirror of
https://github.com/ION606/linkedin-api.git
synced 2026-05-14 22:06:54 +00:00
added fetching company website pt 2
This commit is contained in:
+11
-6
@@ -67,6 +67,17 @@ export class Company {
|
||||
}
|
||||
|
||||
checkIfCompleted = () => !!(this.name && this.url && this.urn && this.#APIRef);
|
||||
awaitCompanyURL = async () => {
|
||||
try {
|
||||
if (!this.url) return false;
|
||||
const r = await axios.get(this.url);
|
||||
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)}`;
|
||||
return true;
|
||||
}
|
||||
catch (err) { return false; }
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{title: {text: String}, entityUrn: String, navigationUrl: String}} data
|
||||
@@ -80,12 +91,6 @@ 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
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"type": "module",
|
||||
"name": "linkedin-api-js",
|
||||
"version": "1.0.0-20",
|
||||
"version": "1.0.0-21",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
Reference in New Issue
Block a user