From 7f202b1a0d05f9e3bc3e3cec3d354b68454b99bd Mon Sep 17 00:00:00 2001 From: unwox Date: Tue, 8 Apr 2025 21:41:52 +0600 Subject: artoftea: finally fix the prices! [2] --- parser/artoftea.fnl | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'parser/artoftea.fnl') diff --git a/parser/artoftea.fnl b/parser/artoftea.fnl index 386dc77..1421a86 100644 --- a/parser/artoftea.fnl +++ b/parser/artoftea.fnl @@ -21,26 +21,30 @@ (parser.anywhere (parser.tag :a {:class "product-thumb__name" :href "*"} (peg.Cg (parser.till "") :title))) - (+ - (* - (parser.anywhere + (parser.anywhere + (+ + (* (parser.tag :option {:data-price-prefix "*" - :data-price (peg.Cg (parser.till "\"") :price) + :data-price (peg.Cg (parser.till "\"") :amount) :value "*" :selected "selected"} - (peg.Cg (parser.till "") :weight))) - (parser.anywhere - (parser.tag :span {:data-price "*" :class "*"} + (peg.Cg (parser.till "") :weight)) + (parser.anywhere + (parser.tag :span {:data-price (peg.Cg (parser.till "\"") :price) + :class "*"} + (parser.till "")))) + (parser.tag :span {:data-price (peg.Cg (parser.till "\"") :price) + :class "*"} (parser.till "")))) - (parser.anywhere - (parser.tag :span {:data-price "*" :class "*"} - (peg.Cg (parser.till "") :price)))) (parser.anywhere (parser.tag :span {} "В корзину")))) (fn normalize [product] (local year (parser.guess-year product.title)) (local weight (or (parser.guess-weight product.weight ["г"]) (parser.guess-weight product.title))) - (local price (number.string->number product.price)) + (local amount (if product.amount + (number.string->number product.amount) + 1)) + (local price (* (number.string->number product.price) amount)) {:site "artoftea" :title product.title -- cgit v1.2.3