fix: surface parsing errors instead of silently discarding them
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:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user