mirror of
https://github.com/tenox7/wrp.git
synced 2025-02-16 18:30:27 +00:00
add useragent override flag
This commit is contained in:
parent
85d64a3577
commit
43df501d97
4
wrp.go
4
wrp.go
@ -53,6 +53,7 @@ var (
|
|||||||
fgeom = flag.String("g", "1152x600x216", "Geometry: width x height x colors, height can be 0 for unlimited")
|
fgeom = flag.String("g", "1152x600x216", "Geometry: width x height x colors, height can be 0 for unlimited")
|
||||||
htmFnam = flag.String("ui", "wrp.html", "HTML template file for the UI")
|
htmFnam = flag.String("ui", "wrp.html", "HTML template file for the UI")
|
||||||
delay = flag.Duration("s", 2*time.Second, "Delay/sleep after page is rendered and before screenshot is taken")
|
delay = flag.Duration("s", 2*time.Second, "Delay/sleep after page is rendered and before screenshot is taken")
|
||||||
|
userAgent = flag.String("ua", "", "override chrome user agent")
|
||||||
srv http.Server
|
srv http.Server
|
||||||
actx, ctx context.Context
|
actx, ctx context.Context
|
||||||
acncl, cncl context.CancelFunc
|
acncl, cncl context.CancelFunc
|
||||||
@ -563,6 +564,9 @@ func main() {
|
|||||||
chromedp.Flag("headless", *headless),
|
chromedp.Flag("headless", *headless),
|
||||||
chromedp.Flag("hide-scrollbars", false),
|
chromedp.Flag("hide-scrollbars", false),
|
||||||
)
|
)
|
||||||
|
if *userAgent != "" {
|
||||||
|
opts = append(opts, chromedp.UserAgent(*userAgent))
|
||||||
|
}
|
||||||
actx, acncl = chromedp.NewExecAllocator(context.Background(), opts...)
|
actx, acncl = chromedp.NewExecAllocator(context.Background(), opts...)
|
||||||
defer acncl()
|
defer acncl()
|
||||||
ctx, cncl = chromedp.NewContext(actx)
|
ctx, cncl = chromedp.NewContext(actx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user