chore: chromium browser asnc handling

This commit is contained in:
PeriniM 2025-01-06 04:08:15 +01:00
parent a82af04afe
commit 5be7c497cd

View File

@ -325,14 +325,13 @@ class ChromiumLoader(BaseLoader):
await page.wait_for_load_state(self.load_state)
results = await page.content()
logger.info("Content scraped")
await browser.close()
return results
except (aiohttp.ClientError, asyncio.TimeoutError, Exception) as e:
attempt += 1
logger.error(f"Attempt {attempt} failed: {e}")
if attempt == self.retry_limit:
raise RuntimeError(f"Failed to scrape after {self.retry_limit} attempts: {str(e)}")
finally:
await browser.close()
async def ascrape_with_js_support(self, url: str, browser_name: str = "chromium") -> str:
"""