mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-14 02:36:21 +02:00
**Problem:**
AI was detecting old crossed-out prices instead of current prices.
Example: Stokomani Lutin - Current: 19,99€, Old (strikethrough): 14,99€
AI detected: 14.99 EUR (wrong - old price)
**Root Cause:**
Generic price extraction was finding ALL price elements without checking
if they were visually crossed-out (text-decoration: line-through).
Many e-commerce sites show:
```html
<span class="old-price" style="text-decoration: line-through">14,99 €</span>
<span class="price">19,99 €</span>
```
The selector finds both, but we were returning the first found.
**Solution: Check CSS text-decoration**
Added strikethrough detection (browserless_service.py:182-189):
```python
# Check if element is strikethrough (old price)
text_decoration = await element.evaluate(
"el => window.getComputedStyle(el).textDecoration"
)
if "line-through" in text_decoration:
continue # Skip crossed-out prices
```
**Flow:**
```
Found elements with .price selector: [elem1, elem2, elem3]
↓
For each element:
1. Check visibility ✓
2. Check text-decoration
→ "line-through" → SKIP ✓
→ "none" → CONTINUE
3. Extract price text
↓
Return first non-strikethrough price
```
**CSS Patterns Detected:**
- `text-decoration: line-through` (most common)
- `text-decoration: line-through solid`
- Combined styles ignored if they don't contain "line-through"
**Expected Results:**
- Before: Returns first price found (14.99 if it's first in DOM)
- After: Skips strikethrough prices, returns current price (19.99)
**Note:** Existing selector already excludes common classes:
`:not([class*='old']):not([class*='was']):not([class*='original'])`
This adds runtime CSS check as additional safety layer.
Partial fix for Stokomani Lutin 14.99 vs 19.99 issue.
May need site-specific selectors if problem persists.