mirror of
https://github.com/tnypxl/rollup.git
synced 2025-12-15 15:03:17 +00:00
feat: Improve content extraction with fallback to body
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user