Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/extend selector handling of scraper for more use cases (#5047)

Thomas Kaul3fcd611e2904
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 940093881e..a4c68125b6 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 bcaa77a173..5cc9c58be9 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
});
}
}