feat(render): --extract-text flag for hybrid output (tiles + text.md) - #106
Conversation
Adds an opt-in text extraction mode to pixelshot that saves a text.md file alongside the screenshot tiles. Uses CDP Runtime.evaluate to grab document.body.innerText after the page is rendered — zero-cost since the DOM is already open. Usage: pixelshot https://example.com -o ./tiles --extract-text Output: tiles/example.com.png.tiles/ ├── tile_0000.jpg # visual tile (existing) ├── text.md # page text as markdown (new) └── tiles.json # manifest This enables hybrid workflows where LLMs receive text for text-heavy paragraphs (cheap tokens) and images only for charts/tables/diagrams (expensive vision tokens). Addresses StarTrail-org#93.
|
@aafaq-rashid-comprinno is attempting to deploy a commit to the andylizf's projects Team on Vercel. A member of the Team first needs to authorize it. |
Verifies text.md is created with page content when extract_text=True, and not created when the flag is off (default).
…ilures render_urls picks the turbo backend whenever the installed Chrome is turbo-capable, which is what `pixelshot install-chrome` produces. fast_cdp has no text extraction, so --extract-text produced tiles and no text.md with nothing logged. Added extract_text to the capability guard that already sends wait_network_idle down the standard path, and logged the downgrade the same way. Also replaced the bare `except: pass` around the innerText probe with a warning — still best-effort, but no longer silent.
|
Merging this. I pushed one commit to your branch rather than sending it back — the flag was silently a no-op for most users. The gap: The fix is one line in the capability guard that already exists right above your change: if use_turbo and (
image_format != "jpeg"
or viewport_width != VIEWPORT_W
or wait_network_idle
or extract_text # <- added
or not from_surface
):plus the matching I also added Last thing, and this one is not a blocker: the If you want a follow-up: teaching fast_cdp the same |
Addresses #93.
Problem
Passing full screenshot tiles to LLMs costs many vision tokens. For text-heavy pages, extracting the text alongside the visual tiles lets users choose the cheaper representation when no charts/tables are present.
Solution
New
--extract-textflag forpixelshotthat extractsdocument.body.innerTextvia CDP after the page is rendered and saves it astext.mdin the tile directory.Output:
Design decisions
innerTextis a single CDP call--extract-textis off by default)Tested