Comments (8)
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.
from rod.
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 Emulation.setDeviceMetricsOverride
to do it:
I think this kind of solution is good to have.
from rod.
To make the chrome version consistent, you can download a specific version of chrome and specified the bin location:
launcher.New().Bin("the_path_of_chrome")
Or you can check this FAQ to use docker: https://github.com/ysmood/rod#q-how-to-use-rod-with-docker
from rod.
Published v0.34.2
with the full page screenshot feature.
I changed the name to SceenshotFullPage
, so that when user types Screenshot
the IDE will give the user a list to choose which one to use.
Because of the retina scale bug, I have to revert the GetViewport
, the safest way to do it is to store a private viewport whenever we set it, once chrome adds the API to retrieve the metrics we can optimize it.
from rod.
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)
from rod.
How about to use page.PDF()
?
from rod.
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... 😆
from rod.
Both page.PDF()
and page.PDFE()
returns
2020/05/19 15:37:54 {"code":-32000,"message":"PrintToPDF is not implemented","data":""}
@ysmood I'm more than happy with helping!
from rod.
Related Issues (20)
- Ignoring the error "element's pointer-events is none" HOT 2
- 进程启动被杀后 无法退出 导致锁死 HOT 3
- Upload file on Managed Launcher? HOT 2
- Does rod support separate sessions or incognito mode? HOT 2
- if err == nil 后的逻辑不会执行 HOT 1
- Google Login not working when browser is started with Rod HOT 11
- Screenshot in Emulate error HOT 3
- Notice! ! ! Can I modify Lanucher's proxy here again? HOT 3
- Some website load fail without -rod=show HOT 3
- Get all javascript or css resources of the same-origin HOT 3
- page.MustExpose not work in launcher.NewAppMode() HOT 2
- Is it correct for me to call stealth like this? I want the entire browser to pass detection effectively, not a single page. Code: HOT 2
- Resources content is nil HOT 2
- rod resets settings of a chrome profile HOT 2
- Chinese garbled code HOT 2
- 浏览器的角标怎么设置? HOT 2
- 并发page pool, context deadline exceeded,page为什么没有释放? HOT 2
- Add support for Linux Arm? for downloading etc. HOT 4
- Add an initEvents public function with a Browser structure HOT 5
- page.Navigate(url), the page is like blocked HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rod.