From 8099dae3ce17035caeb04f7f9f8b11004bb806d9 Mon Sep 17 00:00:00 2001 From: Pachakutiq <101460915+PACHAKUTlQ@users.noreply.github.com> Date: Thu, 10 Apr 2025 15:35:54 +0800 Subject: [PATCH] fix: Remove duplicated results in google/search.go --- google/search.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/google/search.go b/google/search.go index 78e27e3..491bdd6 100644 --- a/google/search.go +++ b/google/search.go @@ -281,6 +281,23 @@ func (gogl *Google) Search(query core.Query) ([]core.SearchResult, error) { srchRes.URL = href.String() } + // Skip if URL is empty or we've already seen this URL + if srchRes.URL == "" { + continue + } + + // Check for duplicates + isDuplicate := false + for _, existing := range searchResults { + if existing.URL == srchRes.URL { + isDuplicate = true + break + } + } + if isDuplicate { + continue + } + // Get description using multiple fallback strategies desc := "" if descTag, err := resEl.Element("div[data-sncf='1'] div"); err == nil {