fix: surface parsing errors instead of silently discarding them
All checks were successful
CI / vet (pull_request) Successful in 1m10s
CI / build (pull_request) Successful in 1m21s
CI / test (pull_request) Successful in 1m28s

Return errors for required fields (ID, price) and log warnings for
optional fields (title, description, unit price) across all site
extractors instead of silently discarding them with _ =.

Closes #24
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 16:31:56 +00:00
parent 7f24e97131
commit a9711ce904
4 changed files with 77 additions and 27 deletions

View File

@@ -3,6 +3,7 @@ package google
import (
"context"
"fmt"
"log/slog"
"net/url"
"gitea.stevedudenhoeffer.com/steve/go-extractor"
@@ -117,13 +118,19 @@ func (c Config) Search(ctx context.Context, b extractor.Browser, query string) (
titles := s.Select("div > div > div a > h3")
if len(titles) != 0 {
title, _ = titles[0].Text()
title, err = titles[0].Text()
if err != nil {
slog.Warn("failed to get result title", "err", err)
}
}
descs := s.Select("div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span:not([class])")
if len(descs) != 0 {
desc, _ = descs[0].Text()
desc, err = descs[0].Text()
if err != nil {
slog.Warn("failed to get result description", "err", err)
}
}
res = append(res, Result{