Browse Source

Improve handling of missing scraper configuration

pull/757/head
Thomas 3 years ago
parent
commit
c81580366b
  1. 12
      apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts

12
apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts

@ -50,16 +50,18 @@ export class GhostfolioScraperApiService implements DataProviderInterface {
const [symbolProfile] = await this.symbolProfileService.getSymbolProfiles(
[symbol]
);
const scraperConfiguration = symbolProfile?.scraperConfiguration;
const { selector, url } = symbolProfile.scraperConfiguration;
const get = bent(scraperConfiguration?.url, 'GET', 'string', 200, {});
if (selector === undefined || url === undefined) {
return {};
}
const get = bent(url, 'GET', 'string', 200, {});
const html = await get();
const $ = cheerio.load(html);
const value = this.extractNumberFromString(
$(scraperConfiguration?.selector).text()
);
const value = this.extractNumberFromString($(selector).text());
return {
[symbol]: {

Loading…
Cancel
Save