This commit is contained in:
@@ -61,8 +61,18 @@ async def screenshot_url_service(decoded_url, full_page=True):
|
||||
|
||||
async def screenshot_operation(page):
|
||||
try:
|
||||
await page.goto(decoded_url, wait_until='networkidle', timeout=30000)
|
||||
await page.wait_for_timeout(1000)
|
||||
# Start navigation early, then wait for progressively stronger load signals.
|
||||
await page.goto(decoded_url, wait_until='domcontentloaded', timeout=30000)
|
||||
await page.wait_for_load_state('load', timeout=30000)
|
||||
|
||||
# Wait until the browser reports full document readiness.
|
||||
await page.wait_for_function("document.readyState === 'complete'", timeout=30000)
|
||||
|
||||
# Ensure network has gone quiet so dynamic requests can finish.
|
||||
await page.wait_for_load_state('networkidle', timeout=30000)
|
||||
|
||||
# Allow a brief settle period for final paints/animations.
|
||||
await page.wait_for_timeout(1500)
|
||||
screenshot_bytes = await page.screenshot(full_page=full_page, type='png')
|
||||
return screenshot_bytes
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user