Fix Best Buy scraper picking up payment plan prices

- Add global filter in priceParser to reject monthly/payment plan prices
- Filters: "/mo", "per month", "payments starting", "4 payments", etc.
- Update Best Buy scraper to check each price element for payment terms
- Prevents scraping "$25/mo" instead of actual "$229.99" price

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
clucraft 2026-01-24 04:01:16 -05:00
parent 710e4c0483
commit 40c45b49c8
2 changed files with 34 additions and 5 deletions

View file

@ -37,6 +37,20 @@ export function parsePrice(text: string): ParsedPrice | null {
// Clean up the text
const cleanText = text.trim().replace(/\s+/g, ' ');
// Reject monthly payment/financing prices (e.g., "$25/mo", "per month", "4 payments", etc.)
const lowerText = cleanText.toLowerCase();
if (lowerText.includes('/mo') ||
lowerText.includes('per month') ||
lowerText.includes('monthly payment') ||
lowerText.includes('a month') ||
lowerText.includes('payments starting') ||
lowerText.includes('payment of') ||
lowerText.includes('payments of') ||
/\d+\s*payments?\b/.test(lowerText) ||
/\d+\s*mo\b/.test(lowerText)) {
return null;
}
for (const pattern of pricePatterns) {
const match = cleanText.match(pattern);
if (match && match.groups) {