From 73687822ad7c4fb90472872769b9fe0e4fc33fb8 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 9 May 2024 18:00:58 -0700 Subject: [PATCH] Update main.py --- apps/playwright-service/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/playwright-service/main.py b/apps/playwright-service/main.py index 7a6e620..4ffc711 100644 --- a/apps/playwright-service/main.py +++ b/apps/playwright-service/main.py @@ -8,6 +8,7 @@ app = FastAPI() class UrlModel(BaseModel): url: str + wait: int = None browser: Browser = None @@ -29,7 +30,9 @@ async def shutdown_event(): async def root(body: UrlModel): context = await browser.new_context() page = await context.new_page() - await page.goto(body.url) + await page.goto(body.url, timeout=15000) # Set max timeout to 15s + if body.wait: # Check if wait parameter is provided in the request body + await page.wait_for_timeout(body.wait) # Convert seconds to milliseconds for playwright page_content = await page.content() await context.close() json_compatible_item_data = {"content": page_content}