diff --git a/internal/parsers/mandarake/service.go b/internal/parsers/mandarake/service.go index f3e191a..1fb2757 100644 --- a/internal/parsers/mandarake/service.go +++ b/internal/parsers/mandarake/service.go @@ -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)