Clarifying wait type and name

This commit is contained in:
Matt Joyce 2024-06-01 13:46:16 +10:00
parent c516140bfb
commit 1eacad4ef3

View File

@ -20,7 +20,7 @@ app = FastAPI()
class UrlModel(BaseModel): class UrlModel(BaseModel):
"""Model representing the URL and associated parameters for the request.""" """Model representing the URL and associated parameters for the request."""
url: str url: str
wait: int = None wait_after_load: int = 0
timeout: int = 15000 timeout: int = 15000
browser: Browser = None browser: Browser = None
@ -67,8 +67,8 @@ async def root(body: UrlModel):
timeout=body.timeout, timeout=body.timeout,
) )
# Wait != timeout. Wait is the time to wait after the page is loaded - useful in some cases were "load" / "networkidle" is not enough # Wait != timeout. Wait is the time to wait after the page is loaded - useful in some cases were "load" / "networkidle" is not enough
if body.wait: if body.wait_after_load > 0:
await page.wait_for_timeout(body.wait) await page.wait_for_timeout(body.wait_after_load)
page_content = await page.content() page_content = await page.content()
await context.close() await context.close()