From 55c4b0ad41d3bd921809057bde4aff412f7840a3 Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Thu, 10 Apr 2025 04:36:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BC=98=E5=8C=96=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=88=AA?= =?UTF-8?q?=E5=9B=BE=E7=88=86=E7=82=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_tetris_stats/utils/screenshot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonebot_plugin_tetris_stats/utils/screenshot.py b/nonebot_plugin_tetris_stats/utils/screenshot.py index 52029d5..40215f1 100644 --- a/nonebot_plugin_tetris_stats/utils/screenshot.py +++ b/nonebot_plugin_tetris_stats/utils/screenshot.py @@ -16,6 +16,7 @@ async def screenshot(url: str) -> bytes: context = await BrowserManager.get_context('screenshot', factory=context_factory) async with await context.new_page() as page: await page.goto(url) + await page.wait_for_selector('#content') size: ViewportSize = await page.evaluate(""" () => { const element = document.querySelector('#content'); @@ -26,5 +27,4 @@ async def screenshot(url: str) -> bytes: }; """) await page.set_viewport_size(size) - await page.wait_for_load_state('networkidle') return await page.locator('id=content').screenshot(animations='disabled', timeout=5000, type='png')