From 3fcd611e29044d52834dc28125cf361149f1931d Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 28 Jun 2025 15:50:50 +0200 Subject: [PATCH] Feature/extend selector handling of scraper for more use cases (#5047) * Extend selector handling for more use cases * Update changelog --- CHANGELOG.md | 1 + .../data-provider/manual/manual.service.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 940093881..a4c68125b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Extended the selector handling of the scraper configuration for more use cases - Changed `node main` to `exec node main` in the `entrypoint.sh` file to improve the container signal handling - Improved the language localization for Catalan (`ca`) - Improved the language localization for Dutch (`nl`) diff --git a/apps/api/src/services/data-provider/manual/manual.service.ts b/apps/api/src/services/data-provider/manual/manual.service.ts index bcaa77a17..5cc9c58be 100644 --- a/apps/api/src/services/data-provider/manual/manual.service.ts +++ b/apps/api/src/services/data-provider/manual/manual.service.ts @@ -303,9 +303,21 @@ export class ManualService implements DataProviderInterface { } catch {} } + let value = $(scraperConfiguration.selector).first().text(); + + const lines = value?.split('\n') ?? []; + + const lineWithDigits = lines.find((line) => { + return /\d/.test(line); + }); + + if (lineWithDigits) { + value = lineWithDigits; + } + return extractNumberFromString({ locale, - value: $(scraperConfiguration.selector).first().text() + value }); } }