Skip to content

Commit

Permalink
Merge pull request #66 from snowykami/master
Browse files Browse the repository at this point in the history
✨ 增加浏览器控制台内容的输出,在日志等级为DEBUG的时候输出
  • Loading branch information
kexue-z committed Jun 1, 2024
2 parents fec41da + bee0e70 commit 567cf86
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nonebot_plugin_htmlrender/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ async def html_to_pic(
if "file:" not in template_path:
raise Exception("template_path 应该为 file:///path/to/template")
async with get_new_page(device_scale_factor, **kwargs) as page:
page.on("console", lambda msg: logger.debug(f"浏览器控制台: {msg.text}"))
await page.goto(template_path)
await page.set_content(html, wait_until="networkidle")
await page.wait_for_timeout(wait)
Expand Down Expand Up @@ -259,6 +260,7 @@ async def capture_element(
**kwargs,
) -> bytes:
async with get_new_page(**kwargs) as page:
page.on("console", lambda msg: logger.debug(f"浏览器控制台: {msg.text}"))
await page.goto(url, timeout=timeout)
return await page.locator(element).screenshot(
type=type,
Expand Down

0 comments on commit 567cf86

Please sign in to comment.