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:
@@ -445,6 +445,9 @@ class AsyncPlaywrightCrawlerStrategy(AsyncCrawlerStrategy):
|
|||||||
return await self._crawl_web(url, config)
|
return await self._crawl_web(url, config)
|
||||||
|
|
||||||
elif url.startswith("file://"):
|
elif url.startswith("file://"):
|
||||||
|
# initialize empty lists for console messages
|
||||||
|
captured_console = []
|
||||||
|
|
||||||
# Process local file
|
# Process local file
|
||||||
local_file_path = url[7:] # Remove 'file://' prefix
|
local_file_path = url[7:] # Remove 'file://' prefix
|
||||||
if not os.path.exists(local_file_path):
|
if not os.path.exists(local_file_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user