maybe with scroll
Build and Push Docker Images / build-and-push (push) Successful in 31s

This commit is contained in:
2026-03-27 10:18:23 +01:00
parent 82173865d7
commit 6b2c06d8fd
@@ -71,6 +71,44 @@ async def screenshot_url_service(decoded_url, full_page=True):
# Ensure network has gone quiet so dynamic requests can finish. # Ensure network has gone quiet so dynamic requests can finish.
await page.wait_for_load_state('networkidle', timeout=30000) await page.wait_for_load_state('networkidle', timeout=30000)
# Scroll to trigger lazy-loaded/infinite content until height stabilizes.
await page.evaluate("""async () => {
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
let previousHeight = 0;
let stableRounds = 0;
const maxRounds = 30;
for (let i = 0; i < maxRounds; i++) {
const currentHeight = Math.max(
document.body.scrollHeight,
document.documentElement.scrollHeight
);
window.scrollTo(0, currentHeight);
await sleep(700);
const newHeight = Math.max(
document.body.scrollHeight,
document.documentElement.scrollHeight
);
if (newHeight <= previousHeight && newHeight <= currentHeight) {
stableRounds += 1;
if (stableRounds >= 2) {
break;
}
} else {
stableRounds = 0;
}
previousHeight = newHeight;
}
// Return to top for a predictable final render before capture.
window.scrollTo(0, 0);
await sleep(700);
}""")
# Extra settle time so animations/transitions can complete. # Extra settle time so animations/transitions can complete.
await page.wait_for_timeout(5000) await page.wait_for_timeout(5000)
screenshot_bytes = await page.screenshot(full_page=full_page, type='png') screenshot_bytes = await page.screenshot(full_page=full_page, type='png')