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

Request: page.html() #406

Closed
RobertCorey opened this issue Aug 19, 2017 · 5 comments
Closed

Request: page.html() #406

RobertCorey opened this issue Aug 19, 2017 · 5 comments

Comments

@RobertCorey
Copy link

Return the html of the current page. Is there an easy way to do this I'm not seeing?

@RobertCorey
Copy link
Author

RobertCorey commented Aug 19, 2017

I see how to do it now https://github.com/GoogleChrome/puppeteer/blob/master/examples/search.js . I will write an example and submit a pr for the readme.

@ebidel
Copy link
Contributor

ebidel commented Aug 20, 2017

See #331 (comment)

@alex88
Copy link

alex88 commented Aug 20, 2017

If you want a more complete html, including doctype and html tag (which I think is the real page html, not the innerhtml) you can use

const renderedContent = await page.evaluate(() => new XMLSerializer().serializeToString(document));

@ebidel
Copy link
Contributor

ebidel commented Aug 20, 2017

If you want to minimize the alterations added by XMLSerializer:

const html = await page.evaluate('new XMLSerializer().serializeToString(document.doctype) + document.documentElement.outerHTML');

@hasibsahibzada
Copy link

hasibsahibzada commented Jun 22, 2018

Simple just use

const html = await page.content();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants