summaryrefslogtreecommitdiff
path: root/parser/artoftea.fnl
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-12-23 22:25:53 +0600
committerunwox <me@unwox.com>2024-12-23 22:26:10 +0600
commit0413dc0cc0b75bb016dce603d5402bc470440142 (patch)
tree1e739e316507e704f6cddd1602e031cdf21aec3a /parser/artoftea.fnl
parentc070964e142398f55c01c00b02f12015d886bd5c (diff)
improve artoftea parsing
Diffstat (limited to 'parser/artoftea.fnl')
-rw-r--r--parser/artoftea.fnl7
1 files changed, 4 insertions, 3 deletions
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 "</option>") :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