feat: AsyncPlasmateCrawlerStrategy β lightweight alternative to Playwright (no Chrome)#1906
Open
dbhurley wants to merge 1 commit intounclecode:developfrom
Open
feat: AsyncPlasmateCrawlerStrategy β lightweight alternative to Playwright (no Chrome)#1906dbhurley wants to merge 1 commit intounclecode:developfrom
dbhurley wants to merge 1 commit intounclecode:developfrom
Conversation
β¦laywright Closes unclecode#1256 (memory leak in Docker from Chrome) Related to unclecode#1874 (token usage tracking) Plasmate (https://github.com/plasmate-labs/plasmate) is an open-source Rust browser engine that replaces Chrome/Playwright for static pages. No browser process, ~64MB RAM vs ~300MB, 10-100x fewer tokens per page. Changes: - crawl4ai/async_plasmate_strategy.py: AsyncPlasmateCrawlerStrategy - Implements AsyncCrawlerStrategy ABC (drop-in replacement) - Supports output_format: text (default), markdown, som, links - Supports --selector, --header, --timeout flags - Optional fallback_to_playwright=True for JS-heavy SPAs - Subprocess runs in asyncio executor β safe for concurrent use - crawl4ai/__init__.py: export AsyncPlasmateCrawlerStrategy - tests/general/test_plasmate_strategy.py: 20 unit tests Install: pip install plasmate Usage: from crawl4ai import AsyncWebCrawler from crawl4ai.async_plasmate_strategy import AsyncPlasmateCrawlerStrategy strategy = AsyncPlasmateCrawlerStrategy( output_format="markdown", fallback_to_playwright=True, # SPA safety net ) async with AsyncWebCrawler(crawler_strategy=strategy) as crawler: result = await crawler.arun("https://docs.python.org/3/")
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
AsyncPlasmateCrawlerStrategyβ a drop-in alternative toAsyncPlaywrightCrawlerStrategyusing Plasmate instead of Chrome.Directly addresses:
What Plasmate is
Open-source Rust browser engine (Apache 2.0). Fetches pages and returns them as Structured Object Model (SOM) β a compact, semantically clean representation with nav, ads, cookie banners, and boilerplate stripped. Install:
pip install plasmate.Compression measured across 45 real sites: 17.7Γ average, 77Γ peak. Every token saved before the LLM is a direct cost reduction.
Drop-in usage
What changed
crawl4ai/async_plasmate_strategy.pyAsyncPlasmateCrawlerStrategyimplementingAsyncCrawlerStrategyABCcrawl4ai/__init__.pyAsyncPlasmateCrawlerStrategytests/general/test_plasmate_strategy.pyComparison
fallback_to_playwright=True)playwright install(~300MB browser)pip install plasmateNotes
AsyncPlaywrightCrawlerStrategyusage is untouchedfallback_to_playwright=Truemakes it safe for mixed static/SPA crawlsgather()calls