refactor: 自动截取整页

This commit is contained in:
lixiangwuxian
2024-10-13 16:04:05 +08:00
parent 2290146862
commit 9f5106663f
4 changed files with 19 additions and 7 deletions

View File

@@ -76,6 +76,11 @@ func ScreenshotURL(url, output string, width, height int, marginTop, marginBotto
ignoreErrors(queryAction), // 等待指定元素
chromedp.Sleep(5*time.Second),
chromedp.ActionFunc(func(ctx context.Context) error { // 自定义截图逻辑
layoutViewport, _, _, _, _, _, _ := page.GetLayoutMetrics().Do(ctx)
if width == 0 || height == 0 {
width = int(layoutViewport.ClientWidth)
height = int(layoutViewport.ClientHeight)
}
// 计算调整后的截图区域
clip := &page.Viewport{
X: float64(marginLeft),