Created
April 13, 2024 21:19
-
-
Save fawazahmed0/6178ba1380df7ca3acd486ea2ca68e04 to your computer and use it in GitHub Desktop.
save mhtml in playwright
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { chromium } = require('playwright'); | |
const fs = require('node:fs/promises'); | |
(async () => { | |
const browser = await chromium.launch(); | |
const context = await browser.newContext(); | |
const page = await context.newPage(); | |
await page.goto('https://playwright.dev/'); | |
const session = await context.newCDPSession(page) | |
const {data:mhtmlData} = await session.send('Page.captureSnapshot') | |
await fs.writeFile('./mynewmhtml.mhtml', mhtmlData) | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment