Feature/improve handling of scraper configuration (#757)
* Improve handling of missing scraper configuration * Update changelog
This commit is contained in:
parent
5356bf568e
commit
4826a51199
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved the error handling in the scraper configuration
|
||||
|
||||
## 1.126.0 - 14.03.2022
|
||||
|
||||
### Added
|
||||
|
@ -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…
x
Reference in New Issue
Block a user