summaryrefslogtreecommitdiff
path: root/parser/artoftea.fnl
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2025-04-08 21:41:52 +0600
committerunwox <me@unwox.com>2025-04-08 21:41:52 +0600
commit7f202b1a0d05f9e3bc3e3cec3d354b68454b99bd (patch)
tree4746d3f3d8e4a938195f1b40514f8e3cf545985d /parser/artoftea.fnl
parenta7ec526534548f42d452e83c6c573202703fd932 (diff)
artoftea: finally fix the prices! [2]
Diffstat (limited to 'parser/artoftea.fnl')
-rw-r--r--parser/artoftea.fnl26
1 files changed, 15 insertions, 11 deletions
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 "</a>") :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 "</option>") :weight)))
- (parser.anywhere
- (parser.tag :span {:data-price "*" :class "*"}
+ (peg.Cg (parser.till "</option>") :weight))
+ (parser.anywhere
+ (parser.tag :span {:data-price (peg.Cg (parser.till "\"") :price)
+ :class "*"}
+ (parser.till "</span>"))))
+ (parser.tag :span {:data-price (peg.Cg (parser.till "\"") :price)
+ :class "*"}
(parser.till "</span>"))))
- (parser.anywhere
- (parser.tag :span {:data-price "*" :class "*"}
- (peg.Cg (parser.till "</span>") :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