diff --git a/livecrawler/app.py b/livecrawler/app.py index 704e3ac..cc5e627 100644 --- a/livecrawler/app.py +++ b/livecrawler/app.py @@ -44,6 +44,11 @@ def clean_price(v): return float(m.group()) if m else None def price_from_meta(h): + # Shopware/Microdata: itemprop="price" content="..." + mi=re.search(r'itemprop=["\']price["\'][^>]*content=["\']([^"\']+)', h, re.I) or re.search(r'content=["\']([^"\']+)["\'][^>]*itemprop=["\']price["\']', h, re.I) + if mi: + p=clean_price(mi.group(1)); + if p: return p for pat in ("product:price:amount","og:price:amount"): m=re.search(r']+(?:property|name)=["\']'+pat+r'["\'][^>]+content=["\']([^"\']+)', h, re.I) or \ re.search(r']+content=["\']([^"\']+)["\'][^>]+(?:property|name)=["\']'+pat+r'["\']', h, re.I) @@ -74,9 +79,9 @@ def parse(htmltext): online = ("in den warenkorb" in low) or ("lieferung" in low and "nicht möglich" not in low) or (avail and "instock" in avail.lower()) if price is None: price=price_from_meta(htmltext) - if price is None: - mp=_num(htmltext[:200000]) - price=mp + # Plausibilitäts-Schranke: Klimageräte kosten 3-stellig; verwirf Ausreißer (Raten/Versand) + if price is not None and price < 150: + price=None if in_store: availability="in_stock" elif online: availability="online_available" elif price is not None: availability="out_of_stock"