Enhance price parsing to handle non-zero unit price
Updated price extraction logic to set `Price` from `UnitPrice` when it is non-zero, ensuring more accurate parsing.
This commit is contained in:
@@ -117,6 +117,9 @@ func (c Config) GetItemPrice(ctx context.Context, b extractor.Browser, u *url.UR
|
|||||||
if len(units) > 1 {
|
if len(units) > 1 {
|
||||||
res.Unit = strings.TrimSpace(units[1])
|
res.Unit = strings.TrimSpace(units[1])
|
||||||
res.UnitPrice, _ = strconv.ParseFloat(units[0], 64)
|
res.UnitPrice, _ = strconv.ParseFloat(units[0], 64)
|
||||||
|
if res.UnitPrice != 0 {
|
||||||
|
res.Price = res.UnitPrice
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user