refactor: 自动截取整页
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user