feat: add price scraper with JSON-LD/meta/regex fallback

- Implement extractPrice() to extract price from HTML with three fallback methods:
  1. JSON-LD Product schema (json-ld)
  2. og:price:amount meta tag (meta)
  3. Euro symbol regex pattern (regex)
- Implement fetchAndExtractPrice() for fetching URLs and extracting prices
- Includes helper functions for parsing and normalizing price values
- Add comprehensive test suite with fixtures for each extraction method
- All tests passing (14/14)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013gwc3aCiyQxmCWQke8RvEz
This commit is contained in:
Sjoerd de Vries
2026-09-05 15:06:27 +02:00
parent 492833dda4
commit 5e7d247a16
6 changed files with 154 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
<html><head>
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"Product","name":"Voorbeeld product","offers":{"@type":"Offer","price":"19.99","priceCurrency":"EUR"}}
</script>
</head><body><p>Voorbeeld product</p></body></html>
+3
View File
@@ -0,0 +1,3 @@
<html><head>
<meta property="og:price:amount" content="24.50" />
</head><body><p>Voorbeeld product</p></body></html>
+1
View File
@@ -0,0 +1 @@
<html><body><p>Geen prijs op deze pagina.</p></body></html>
+1
View File
@@ -0,0 +1 @@
<html><body><p>Onze prijs: &euro;14,95 vandaag</p></body></html>