md_generator.playwright API Reference¶
Summary¶
| Item | Value |
|---|---|
| Purpose | Convert Rendered web pages and SPAs to Browser-captured Markdown |
| CLI | md-playwright |
| Extra | playwright |
| Tier | medium |
Quick CLI reference¶
| Argument | Type | Required | Default | Choices | Help |
|---|---|---|---|---|---|
url |
str | required | — | — | HTTP or HTTPS URL to fetch |
--output |
Path | optional | Path('.') | — | Output directory (default: current directory) |
--wait |
str | optional | None | — | Optional CSS selector to wait for before scrolling |
--timeout |
float | optional | 60.0 | — | Navigation timeout in seconds (default: 60) |
--user-agent |
str | optional | None | — | Override browser User-Agent |
--wait-until |
str | optional | 'networkidle' | ('load', 'domcontentloaded', 'commit', 'networkidle') | Playwright goto wait_until (default: networkidle) |
--max-scroll-rounds |
int | optional | 12 | — | Max scroll-to-bottom iterations for lazy loading (default: 12) |
--retries |
int | optional | 3 | — | Max fetch attempts with backoff (default: 3) |
--no-chunk |
flag | optional | false | — | Disable chunk markers in output Markdown |
--no-readability |
flag | optional | false | — | Skip readability pass before markdownify |
--screenshot |
Path | optional | None | — | Save full-page PNG screenshot to this path |
--save-raw-html |
Path | optional | None | — | Save raw rendered HTML to this path |
--max-chunk-tokens |
int | optional | 900 | — | Approximate max tokens per chunk (default: 900) |
-v |
flag | optional | false | — | — |
Primary symbols¶
| Symbol | Kind | Notes |
|---|---|---|
| convert_url_to_md | callable | — |
| PlaywrightOptions | callable | — |
Python API (mkdocstrings)¶
playwright ¶
Playwright-based SPA render → Markdown pipeline.
PlaywrightOptions
dataclass
¶
PlaywrightOptions(verbose: bool = False, navigation_timeout_ms: float = 60000.0, user_agent: str = 'mdengine-playwright/0.1 (+https://github.com/mdengine/md-generator)', wait_selector: str | None = None, wait_until: WaitUntil = 'networkidle', max_scroll_rounds: int = 12, scroll_pause_ms: float = 400.0, max_retries: int = 3, retry_backoff_seconds: float = 1.5, headless: bool = True, use_readability: bool = True, chunk_markdown: bool = True, max_chunk_tokens: int = 900, chars_per_token: int = 4, max_images: int = 40, max_image_bytes: int = 5 * 1024 * 1024, asset_timeout_seconds: float = 30.0, screenshot_path: Path | None = None, save_raw_html_path: Path | None = None)
Configuration for SPA fetch → Markdown pipeline.
convert_url_to_md
async
¶
convert_url_to_md(url: str, output_dir: Path | str, options: PlaywrightOptions | None = None) -> Path
Fetch rendered HTML, extract main content, convert to Markdown, download images, chunk, save.