Skip to content
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

How to dump the dom just like chromium --dump-dom #897

Closed
m10x opened this issue Jun 28, 2023 · 4 comments
Closed

How to dump the dom just like chromium --dump-dom #897

m10x opened this issue Jun 28, 2023 · 4 comments
Labels
question Questions related to rod

Comments

@m10x
Copy link

m10x commented Jun 28, 2023

Rod Version: v0.113.3

I want to dump the DOM, after javascript is being executed. Similar to /usr/bin/chromium --headless --no-sandbox --dump-dom URL. However using page.MustHTML() is returning the source code without javascript being executed and I'm not able to find another function which does that.

func runHTMLinHeadless(html string) {
	page := rod.New().MustConnect().MustPage("about:blank")
	page.MustSetDocumentContent(html)
	fmt.Println(page.MustHTML())
}
@m10x m10x added the question Questions related to rod label Jun 28, 2023
@ysmood
Copy link
Member

ysmood commented Jun 28, 2023

Page.GetResource

@m10x
Copy link
Author

m10x commented Jun 28, 2023

GetResource expects an URL, however I want to pass a html string or use page.MustSetDocumentContent(html) just like in the example

@ysmood
Copy link
Member

ysmood commented Jun 29, 2023

Use MustWaitStable:

func runHTMLinHeadless(html string) {
	page := rod.New().MustConnect().MustPage("about:blank")
	page.MustSetDocumentContent(html).MustWaitStable()
	fmt.Println(page.MustHTML())
}

@m10x
Copy link
Author

m10x commented Jun 29, 2023

Thanks this works flawlessly!

@m10x m10x closed this as completed Jun 29, 2023
9viz pushed a commit to 9viz/pratilipi2epub that referenced this issue Jan 4, 2024
* go.mod: Update rod.
* pratilipi2epub.go (getContent): Prefer MustWaitStable over
MustWaitLoad to let JS do its thing.  See go-rod/rod#897.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants