query update
All checks were successful
/ Make image (push) Successful in 38s

This commit is contained in:
nquidox 2025-12-26 16:56:40 +03:00
parent 45e633a8d0
commit dc257c195b

View file

@ -18,12 +18,11 @@ func (s *Parser) getPrice(ctx context.Context, task shared.Task) (int32, error)
prices []int32
)
//get single price
if err := chromedp.Run(ctx,
chromedp.Navigate(task.Link),
chromedp.WaitReady("body"),
chromedp.WaitVisible(`div.price`, chromedp.ByQuery),
chromedp.Text(`div.price`, &singlePrice, chromedp.ByQuery),
chromedp.Text(`div.price`, &singlePrice, chromedp.ByQuery, chromedp.AtLeast(0)),
chromedp.Text(`div.price_range`, &rangedPrice, chromedp.ByQuery, chromedp.AtLeast(0)),
); err != nil {
log.WithError(err).Error(logHeader + logGetPrice + "failed to get single price tag")
return zeroPrice, err
@ -31,23 +30,11 @@ func (s *Parser) getPrice(ctx context.Context, task shared.Task) (int32, error)
singlePrice = strings.TrimSpace(singlePrice)
prices = append(prices, s.getSinglePriceWithTax(singlePrice))
//get price range
if err := chromedp.Run(ctx,
chromedp.Navigate(task.Link),
chromedp.WaitReady("body"),
chromedp.WaitVisible(`price_range`, chromedp.ByQuery),
chromedp.Text(`price_range`, &rangedPrice, chromedp.ByQuery),
); err != nil {
log.WithError(err).Warn(logHeader + logGetPrice + "failed to get ranged price tag")
}
rangedPrice = strings.TrimSpace(rangedPrice)
if rangedPrice != "" {
prices = append(prices, s.getMinimalPriceFromRangeWithTax(rangedPrice))
}
//get minimal price
minimal := slices.Min(prices)
log.Infof(logHeader+"uuid: %s, price: %d", task.MerchUuid, minimal)