added fetching company website

This commit is contained in:
2024-05-30 15:35:16 -04:00
parent 6e02057a97
commit 4e5fa6aa6b
4 changed files with 14 additions and 5 deletions
+8
View File
@@ -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!";
}
}