From 0413dc0cc0b75bb016dce603d5402bc470440142 Mon Sep 17 00:00:00 2001 From: unwox Date: Mon, 23 Dec 2024 22:25:53 +0600 Subject: improve artoftea parsing --- parser/artoftea.fnl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'parser/artoftea.fnl') diff --git a/parser/artoftea.fnl b/parser/artoftea.fnl index 773f038..5c7efff 100644 --- a/parser/artoftea.fnl +++ b/parser/artoftea.fnl @@ -26,8 +26,7 @@ (* (parser.anywhere (parser.tag :option {:value "*" :selected "selected"} - (* (peg.Cg parser.pegs.number :weight) (+ (peg.P "г") " гр") - parser.pegs.spaces))) + (peg.Cg (parser.till "") :weight))) (parser.anywhere (parser.tag :p {:class "price"} (parser.tag :span {:id "*"} @@ -41,8 +40,10 @@ (fn normalize [product] (local year (parser.guess-year product.title)) - (local weight (number.string->number product.weight)) + (local weight (or (parser.guess-weight product.weight ["г"]) + (parser.guess-weight product.title))) (local price (number.string->number product.price)) + {:site "artoftea" :title product.title :url product.url -- cgit v1.2.3