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()
|
visited: Set[str] = set()
|
||||||
depths = {start_url: 0}
|
depths = {start_url: 0}
|
||||||
active_crawls = set() # Track URLs currently being processed
|
active_crawls = set() # Track URLs currently being processed
|
||||||
|
async with AsyncWebCrawler(
|
||||||
|
config=browser_config,
|
||||||
|
verbose=True,
|
||||||
|
) as crawler:
|
||||||
try:
|
try:
|
||||||
while (
|
while (
|
||||||
not queue.empty() or active_crawls
|
not queue.empty() or active_crawls
|
||||||
@@ -161,10 +165,6 @@ class BFSScraperStrategy(ScraperStrategy):
|
|||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
continue
|
continue
|
||||||
# Process batch
|
# Process batch
|
||||||
async with AsyncWebCrawler(
|
|
||||||
config=browser_config,
|
|
||||||
verbose=True,
|
|
||||||
) as crawler:
|
|
||||||
try:
|
try:
|
||||||
async for result in await crawler.arun_many(
|
async for result in await crawler.arun_many(
|
||||||
urls=[url for _, _, url in jobs],
|
urls=[url for _, _, url in jobs],
|
||||||
|
|||||||
Reference in New Issue
Block a user