feat: Improve content extraction with fallback to body

This commit is contained in:
Arik Jones (aider)
2024-09-14 17:05:05 -05:00
parent f4c368e112
commit eaa7135eab

View File

@@ -253,7 +253,11 @@ func ExtractContentWithCSS(content, includeSelector string, excludeSelectors []s
selection := doc.Find(includeSelector) selection := doc.Find(includeSelector)
if selection.Length() == 0 { if selection.Length() == 0 {
return "", fmt.Errorf("no content found with CSS selector: %s", includeSelector) log.Printf("Warning: No content found with CSS selector: %s. Falling back to body content.\n", includeSelector)
selection = doc.Find("body")
if selection.Length() == 0 {
return "", fmt.Errorf("no content found in body")
}
} }
for _, excludeSelector := range excludeSelectors { for _, excludeSelector := range excludeSelectors {