From 7d0de51fe64ac8d8017f0b9c1a98567acdb92efc Mon Sep 17 00:00:00 2001 From: liuzj288 Date: Mon, 26 Sep 2022 16:55:27 +0800 Subject: [PATCH 1/2] Update brower.py --- LittlePaimon/utils/brower.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LittlePaimon/utils/brower.py b/LittlePaimon/utils/brower.py index cbec8fd1..aa4dae98 100644 --- a/LittlePaimon/utils/brower.py +++ b/LittlePaimon/utils/brower.py @@ -152,9 +152,9 @@ async def screenshot( else: card = page if path: - img = await card.screenshot(path=path, timeout=timeout) + img = await card.screenshot(path=path, timeout=timeout, full_page=True) else: - img = await card.screenshot(timeout=timeout) + img = await card.screenshot(timeout=timeout, full_page=True) return MessageSegment.image(img) except Exception as e: logger.warning(f"Playwright 截图 url:{url} element:{element} 发生错误 {type(e)}:{e}") From e6717f234481ef4bc74ab096d54468155f5a8b9c Mon Sep 17 00:00:00 2001 From: liuzj288 Date: Mon, 26 Sep 2022 16:59:05 +0800 Subject: [PATCH 2/2] Update brower.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 网页截图增加full_page配置项,如果为full_page=True,则获取完整可滚动页面的屏幕截图,而不是当前可见的视口。默认为False,修改源码full_page=True即可启用 --- LittlePaimon/utils/brower.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LittlePaimon/utils/brower.py b/LittlePaimon/utils/brower.py index aa4dae98..687f9578 100644 --- a/LittlePaimon/utils/brower.py +++ b/LittlePaimon/utils/brower.py @@ -152,9 +152,9 @@ async def screenshot( else: card = page if path: - img = await card.screenshot(path=path, timeout=timeout, full_page=True) + img = await card.screenshot(path=path, timeout=timeout, full_page=False) else: - img = await card.screenshot(timeout=timeout, full_page=True) + img = await card.screenshot(timeout=timeout, full_page=False) return MessageSegment.image(img) except Exception as e: logger.warning(f"Playwright 截图 url:{url} element:{element} 发生错误 {type(e)}:{e}")