|
|
@@ -4,7 +4,6 @@ import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"github.com/chromedp/chromedp"
|
|
|
- "io/ioutil"
|
|
|
"log"
|
|
|
"time"
|
|
|
|
|
|
@@ -82,19 +81,20 @@ func (self *ToolController) GetHaibaoWithGoogle() {
|
|
|
chromedp.Navigate(decodedUri), // 替换为你想截图的网页地址
|
|
|
//chromedp.WaitReady("body", chromedp.ByQuery), // 等待页面的 <body> 元素加载完成
|
|
|
chromedp.WaitReady("#overload", chromedp.ByID),
|
|
|
- chromedp.Sleep(5*time.Second),
|
|
|
+ //chromedp.Sleep(5*time.Second),
|
|
|
chromedp.FullScreenshot(&buf, 90), // 调整质量参数
|
|
|
)
|
|
|
if err != nil {
|
|
|
fmt.Println("error occured!")
|
|
|
log.Fatal(err)
|
|
|
}
|
|
|
- fileName := fmt.Sprintf("%s.png", "shot_screen")
|
|
|
- // 将截图保存到文件
|
|
|
- err = ioutil.WriteFile(fileName, buf, 0644)
|
|
|
- if err != nil {
|
|
|
- log.Fatal(err)
|
|
|
- }
|
|
|
+
|
|
|
+ //fileName := fmt.Sprintf("%s.png", "shot_screen")
|
|
|
+ //// 将截图保存到文件
|
|
|
+ //err = ioutil.WriteFile(fileName, buf, 0644)
|
|
|
+ //if err != nil {
|
|
|
+ // log.Fatal(err)
|
|
|
+ //}
|
|
|
|
|
|
//fmt.Println("image buf:", buf)
|
|
|
self.Ctx.Output.Header("Content-Type", "image/png")
|