diff --git a/crawl4ai/content_filter_strategy.py b/crawl4ai/content_filter_strategy.py index ab99a793c..1144ac041 100644 --- a/crawl4ai/content_filter_strategy.py +++ b/crawl4ai/content_filter_strategy.py @@ -683,9 +683,14 @@ def _remove_comments(self, soup): element.extract() def _remove_unwanted_tags(self, soup): - """Removes unwanted tags""" + """Removes unwanted tags, respecting preserve_tags whitelist.""" for tag in self.excluded_tags: for element in soup.find_all(tag): + # Skip elements that match preserve_tags — they should be kept + # even if the tag is in excluded_tags (e.g.,