added fetching company website pt 2

This commit is contained in:
2024-05-30 15:46:01 -04:00
parent 4e5fa6aa6b
commit 13d3b6ceda
2 changed files with 12 additions and 7 deletions
+11 -6
View File
@@ -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
View File
@@ -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"