RFC: optional actionable-snapshot ExtractionStrategy — elements + selectors + state, ~68% lighter than raw_markdown for action-selection
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Read Crawl4AI's ExtractionStrategy implementation and the existing optional LLM strategies to understand how strategies are integrated and dependencies handled. The proposed adapter uses ZeroDOM's parse_html, to_compact_text, and ref_map APIs; the issue says it has been verified against zerodom 0.1.4. If maintainers invite a PR, add the strategy module, a test, and a short docs example; done means it runs through CrawlerRunConfig with HTML input and stays opt-in.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Agents built on top of Crawl4AI that need to act on a page (click/fill) mostly need
one thing from a crawl: the actionable elements and a way to target each. Today the
lightest thing available is cleaned content / markdown — great for reading and
extraction, but it carries the page's prose and doesn't hand back stable selectors to act
with. There's no actionable, selector-backed representation to reach for.
Proposed solution
An opt-in ExtractionStrategy (ZeroDOMExtractionStrategy) that returns a flat,
uniquely-addressable actionable snapshot as extracted_content:
[01] Log in
[02] input Password filled
[03] button Sign in
with the CSS selectors kept out of the model context in a ref_map
({"01": "body > a", ...}) so a downstream agent can act on what it read. State markers
are inline (x checked, empty, filled, active tab…), and sensitive values are
redacted (a filled password/card/CVV/SSN shows as filled, never the value).
It's thin glue over ZeroDOM (zerodom>=0.1.4
on PyPI), already verified to conform and run through Crawl4AI's own run() path with
input_format="html":
from crawl4ai.extraction_strategy import ExtractionStrategy
class ZeroDOMExtractionStrategy(ExtractionStrategy):
def __init__(self, viewport_only=False, with_selectors=True, **kwargs):
kwargs["input_format"] = "html"
super().__init__(**kwargs)
self.viewport_only = viewport_only; self.with_selectors = with_selectors
import zerodom # optional dep; imported only when this strategy is used
def extract(self, url, html, *q, **kwargs):
from zerodom import parse_html
g = parse_html(html or "", url=url, viewport_only=self.viewport_only)
b = {"index": 0, "tags": ["zerodom.snapshot"], "content": g.to_compact_text(terse=True)}
if self.with_selectors: b["ref_map"] = g.ref_map()
return [b]
CrawlerRunConfig(extraction_strategy=ZeroDOMExtractionStrategy())
Fully opt-in: no change to markdown/scraping/other extraction, and no new hard
dependency — zerodom is imported only if you instantiate the strategy (same pattern
as the LLM strategies' optional deps).
Measured — against Crawl4AI's own raw_markdown
Same pages, run through Crawl4AI via raw:// (its real pipeline), tokens via tiktoken
cl100k_base. Snapshot vs the page's own raw_markdown:
| page | raw_markdown | snapshot | fewer |
|---|---|---|---|
| en.wikipedia.org (Web scraping) | 16,717 | 5,178 | 69% |
| docs.python.org/3 | 13,654 | 1,016 | 93% |
| flask.palletsprojects.com | 16,289 | 2,462 | 85% |
| developer.mozilla.org | 3,977 | 1,649 | 59% |
| go.dev | 3,975 | 1,440 | 64% |
| news.ycombinator.com | 4,304 | 2,652 | 38% |
| www.python.org | 4,125 | 1,300 | 68% |
| gov.uk | 2,506 | 693 | 72% |
| www.rust-lang.org | 1,314 | 262 | 80% |
| httpbin.org/forms/post | 51 | 103 | −102% |
Median ~68% fewer tokens across 15 pages. Honest edges: on a trivial form-only page
(httpbin.org/forms/post) the snapshot is larger — there's almost no prose to drop and
the element list has its own floor. And this is deliberately not like-for-like:
markdown is prose for reading/extraction; this is actionable elements for acting. It's
leaner because it drops prose — but it's also the only representation here that carries
selectors + element state, which markdown doesn't. So the win is "a purpose-built, lighter
action representation Crawl4AI doesn't have today," not "a better markdown."
For reference vs other tools (not Crawl4AI): ~1/5 the tokens of Stagehand's
observe() a11y tree and ~49% leaner than agent-browser snapshot -i at matching
coverage — methodology/raw runs in the ZeroDOM repo (benchmarks/). Parse is
deterministic, no LLM, network-free.
Honest scope / caveats
- For the single-shot action-perception use case — not a markdown or data-extraction
replacement (it drops prose by design). - Crawl4AI hands the strategy already-rendered HTML, so state comes from the static
DOM that HTML exposes (aria/native attributes, serialized values). Live-only DOM
properties set purely in JS after render aren't visible to an HTML-only parse.
Alternatives considered
- Trimming markdown/content in place — smaller win, and it couples the action and
extraction paths that want different things. - Keeping it fully external — works today, but a first-class opt-in strategy is where
it actually saves users tokens on the action path without plumbing.
Are you open to an invited PR?
The adapter is written and verified to conform to ExtractionStrategy and run through
Crawl4AI's pipeline against the published zerodom 0.1.4. Happy to open a PR with the
strategy module + a test + a short docs example on your word — wanted to check interest
and get a pointer to where you'd like it to live first.
- Ngôn ngữ chính
- Python
- Star
- 87.2k
- Fork
- 9.1k
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 25
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của unclecode/crawl4ai
-
BUG: UserAgentGenerator.generate ignores browser_type and returns a random browser stackCó thể đã có người làm @HhH666-ux đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Hardened docker-compose (read_only) keeps full Chromium from starting: crashpad needs a writable ~/.configCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở🐞 Bug 📌 Root caused
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
unclecode/crawl4ai#2494 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Feature]: Crawl4aiDockerClient has no public option for the API token the 0.9 server requiresĐang mở⚙ Done ✨ Enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
⚙ Done 🐞 Bug 📌 Root caused
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: PDF images saved with save_images_locally=True come back with an empty src in result.mediaĐang mở⚙ Done 🐞 Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
unclecode/crawl4ai#2469 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của unclecode/crawl4ai
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Install the skills as a Claude Code pluginCó thể đã có người làm @ruban-24 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 6 ngày
-
Make the usage of time-zone aware UTC timestamps the norm across the pynxtools NOMAD ecosystemĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
FAIRmat-NFDI/pynxtools#874 ·
-
Eval: PublicationĐang mởdata
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100