Chromedp简单使用,实现截图和打印pdf
go get github.com/wms3001/goChromedp
- 截图
goChr := &GoChromedp{}
goChr.Url = "https://www.oschina.net"
goChr.Quality = 100
ctx, cancel := goChr.Ctx()
resp := goChr.Screenshot(ctx, cancel)
res, _ := json.Marshal(resp)
log.Println(string(res))
goChr := &GoChromedp{}
goChr.Url = "https://www.oschina.net"
ctx, cancel := goChr.Ctx()
resp := goChr.PrintPdf(ctx, cancel)
res, _ := json.Marshal(resp)
log.Println(string(res))