Skip to content

Instantly share code, notes, and snippets.

@ixuuux
ixuuux / playwright_save_mhtml.py
Last active May 5, 2023 06:00 — forked from mezhgano/playwright_save_mhtml.py
通过playwright将网页保存为mhtml文件
from playwright.sync_api import sync_playwright
def save_mhtml(path: str, text: str):
with open(path, mode='w', encoding='UTF-8', newline='\n') as file:
file.write(text)
def save_page(url: str, path: str):
with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=False)