Skip to content

Instantly share code, notes, and snippets.

@fawazahmed0
Created April 13, 2024 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fawazahmed0/6178ba1380df7ca3acd486ea2ca68e04 to your computer and use it in GitHub Desktop.
Save fawazahmed0/6178ba1380df7ca3acd486ea2ca68e04 to your computer and use it in GitHub Desktop.
save mhtml in playwright
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