-
-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full page screenshot? #32
Comments
How about to use |
I've ended up writing this: func UseRod(link string) {
url := launcher.New().
Headless(false).
Devtools(false).
Launch()
browser := rod.New().
ControlURL(url).
Trace(false).
Connect().
Timeout(time.Minute)
defer browser.Close()
page := browser.Timeout(time.Minute).Page(link)
wait := page.WaitRequestIdle()
wait()
height := page.Eval(`() => document.body.clientHeight`).String()
heightToInt, err := strconv.ParseInt(height, 10, 64)
if err != nil {
log.Fatalln(err)
}
page.Viewport(1920, heightToInt, 1, false)
toByte, err := page.ScreenshotE(&proto.PageCaptureScreenshot{})
f, err := os.Create("img_2.png")
if err != nil {
log.Fatal(err)
}
defer f.Close()
img, _, _ := image.Decode(bytes.NewReader(toByte))
err = png.Encode(f, img)
if err != nil {
log.Fatal(err)
}
} but will try the page.PDF() as well! My solution is a tad verbose... 😆 |
Let's keep this ticket open since the full-page screenshot is actually useful. I just don't have enough time to implement it. The common solution is to take multiple shots while scrolling down the page until it hits the bottom, then merge all those shots into one. If you are interested in it, it'll be great if you can help to implement it. |
Both
@ysmood I'm more than happy with helping! |
If your chrome version is too old, it doesn't support the PDF API. The way you code it is similar to puppeteer, which changes the size of the frame. But puppeteer uses I think this kind of solution is good to have. |
To make the chrome version consistent, you can download a specific version of chrome and specified the bin location:
Or you can check this FAQ to use docker: https://github.com/ysmood/rod#q-how-to-use-rod-with-docker |
Published I changed the name to Because of the retina scale bug, I have to revert the |
Good call! I'll close this one for now then. If you have any more tasks or functionalities you want to implement - hit me up, happy to help :) (I'll probably learn some stuff while using the lib tho, will try to add them here as I go) |
Is there a way in which we could get a screenshot of the whole page full size, not a screenshot of the window size?
The text was updated successfully, but these errors were encountered: