fix: Move the creation of crawler outside the main loop
This commit is contained in:
@@ -135,6 +135,10 @@ class BFSScraperStrategy(ScraperStrategy):
|
||||
visited: Set[str] = set()
|
||||
depths = {start_url: 0}
|
||||
active_crawls = set() # Track URLs currently being processed
|
||||
async with AsyncWebCrawler(
|
||||
config=browser_config,
|
||||
verbose=True,
|
||||
) as crawler:
|
||||
try:
|
||||
while (
|
||||
not queue.empty() or active_crawls
|
||||
@@ -161,10 +165,6 @@ class BFSScraperStrategy(ScraperStrategy):
|
||||
await asyncio.sleep(0.1)
|
||||
continue
|
||||
# Process batch
|
||||
async with AsyncWebCrawler(
|
||||
config=browser_config,
|
||||
verbose=True,
|
||||
) as crawler:
|
||||
try:
|
||||
async for result in await crawler.arun_many(
|
||||
urls=[url for _, _, url in jobs],
|
||||
|
||||
Reference in New Issue
Block a user