Browse Source
Feature/refactor scraper in manual service (#5048)
* Refactoring
pull/5025/head^2
Thomas Kaul
4 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
6 additions and
6 deletions
-
apps/api/src/services/data-provider/manual/manual.service.ts
|
|
@ -286,14 +286,12 @@ export class ManualService implements DataProviderInterface { |
|
|
|
) |
|
|
|
}); |
|
|
|
|
|
|
|
let value: string; |
|
|
|
|
|
|
|
if (response.headers.get('content-type')?.includes('application/json')) { |
|
|
|
const data = await response.json(); |
|
|
|
|
|
|
|
const value = String( |
|
|
|
jsonpath.query(data, scraperConfiguration.selector)[0] |
|
|
|
); |
|
|
|
|
|
|
|
return extractNumberFromString({ locale, value }); |
|
|
|
value = String(jsonpath.query(data, scraperConfiguration.selector)[0]); |
|
|
|
} else { |
|
|
|
const $ = cheerio.load(await response.text()); |
|
|
|
|
|
|
@ -303,7 +301,7 @@ export class ManualService implements DataProviderInterface { |
|
|
|
} catch {} |
|
|
|
} |
|
|
|
|
|
|
|
let value = $(scraperConfiguration.selector).first().text(); |
|
|
|
value = $(scraperConfiguration.selector).first().text(); |
|
|
|
|
|
|
|
const lines = value?.split('\n') ?? []; |
|
|
|
|
|
|
@ -320,5 +318,7 @@ export class ManualService implements DataProviderInterface { |
|
|
|
value |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return extractNumberFromString({ locale, value }); |
|
|
|
} |
|
|
|
} |
|
|
|