首页 > 其他分享 >Chromedp简单使用,实现截图和打印pdf

Chromedp简单使用,实现截图和打印pdf

时间:2022-09-30 14:35:39浏览次数:53  
标签:截图 res resp ctx Chromedp cancel pdf goChr

goChromedp

简介

Chromedp简单使用,实现截图和打印pdf

使用

go get github.com/wms3001/goChromedp

实例

  1. 截图
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))
  1. pdf
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))

标签:截图,res,resp,ctx,Chromedp,cancel,pdf,goChr
From: https://blog.51cto.com/wms3001/5726925

相关文章