fix(crawler): initialize captured_console to prevent unbound local error for local HTML files. REF: #1072

Resolved a bug where running the crawler on local HTML files with `capture_console_messages=False`
(default) raised `UnboundLocalError` due to `captured_console` being accessed before assignment.
This commit is contained in:
ntohidi
2025-05-15 11:29:36 +02:00
parent e0fbd2b0a0
commit 22725ca87b

View File

@@ -445,6 +445,9 @@ class AsyncPlaywrightCrawlerStrategy(AsyncCrawlerStrategy):
return await self._crawl_web(url, config)
elif url.startswith("file://"):
# initialize empty lists for console messages
captured_console = []
# Process local file
local_file_path = url[7:] # Remove 'file://' prefix
if not os.path.exists(local_file_path):