AI Agent Architecture

Scrapling for AI Agents: How One Creator Cut 215K Tokens to 3K

Direct Answer

Scrapling does not give an AI agent a larger context window. It helps the agent waste less of the context it already has. Instead of sending an entire page - navigation, scripts, repeated links, legal text, ads, and all - Scrapling can fetch the page locally and return only the DOM elements that answer the question. That is the useful idea behind Kacper Rutkiewicz's headline.

In his strongest example, raw HTML consumed about 215,000 tokens, Scrapling without a selector used about 13,000, and Scrapling with one CSS selector used about 3,000. The final payload was approximately 71.7 times smaller, a 98.6 percent reduction. It is an impressive demonstration of targeted extraction, but not a general benchmark: the result depends on page size, selector quality, output format, conversation history, tokenizer, and how the agent reports context.

Best use: authorized research, monitoring, and extraction where you know which page region or fields matter. Wrong use: assuming public visibility grants permission, bypassing an explicit block, copying another site's assets, or giving untrusted page content direct control over email, files, publishing, or purchases.

Watch Kacper Rutkiewicz's Test

Video credit: Kacper Rutkiewicz | AI Made Simple. Watch the original video on YouTube. Product behavior, installation, licensing, and fetcher roles were checked against the Scrapling repository and official documentation on 3 August 2026.

ResourceStatusWhy it matters
D4Vinci/ScraplingPrimary project sourceCode, BSD-3-Clause license, releases, issues, and current repository metadata.
Scrapling documentationPrimary product docsInstallation, adaptive parsing, fetchers, spiders, robots support, and supported Python versions.
Scrapling MCP guidePrimary integration docsTen MCP tools, CSS-targeted extraction, session management, prompt-injection sanitation, authentication, and legal guidelines.
FirecrawlPrimary product sourceManaged search, scrape, crawl, interaction, and LLM-ready web data for the hosted comparison.
Imperva 2026 Bad Bot Report summaryVendor researchSupports the video's wider point that automated traffic exceeded human traffic in Imperva's 2025 dataset; it does not validate Scrapling's bypass rate.
BBB Terms of UsePrimary policy sourceImportant correction for the prospect-list demo: BBB restricts aggregation and sales or marketing use.
Kacper's walkthroughCreator testSource for the three workflows and creator-reported token counts.

What Scrapling Actually Is

Scrapling is a Python web-scraping framework, not an LLM. Its parser exposes familiar CSS and XPath selection, text and regex search, DOM traversal, and an adaptive mode that stores element characteristics so it can try to relocate a target after a page changes. Its current project surface also includes HTTP and browser fetchers, persistent sessions, spiders, exports, proxy rotation, an agent skill, a CLI, and an MCP server.

The AI integration is useful because the extraction happens before the text reaches the model. The MCP server can return HTML, Markdown, or cleaned text; apply a CSS selector; keep only main content; reuse browser sessions; and process multiple pages in bulk. That changes the pipeline from "model receives everything, then decides what matters" to "retrieval narrows the evidence, then the model reasons over it."

LayerJobWhat should cross into model context
Policy gateCheck permission, terms, robots rules, rate limits, and purposeA yes/no decision and any usage constraints
FetcherRetrieve the authorized page with the lightest viable methodStatus, source URL, retrieval time, and raw result stored outside the prompt
SelectorKeep only the table, article, cards, or fields requiredSmall, relevant evidence with source metadata
NormalizerDeduplicate, clean, type, and validate fieldsSchema-valid records plus extraction warnings
ModelSummarize, compare, classify, or draftThe minimum evidence needed for the decision
Human gateApprove outreach, publishing, purchases, or changesA reviewable recommendation, not an automatic external action

The 215K-to-3K Token Test

Method in the videoCreator-reported contextRelative payloadInterpretation
Raw HTML sent to Claude Code~215,000 tokensBaselineThe model receives page structure and content whether relevant or not.
Scrapling, no selector~13,000 tokens16.5x smallerParsing and cleaning remove much of the page overhead.
Scrapling, one table selector~3,000 tokens71.7x smallerOnly the requested pricing table crosses the context boundary.

The savings do not come from a magical compression algorithm. They come from retrieval precision. If the answer lives in one table, sending one table is cheaper than sending an entire page. The tradeoff is recall: Kacper's table selector lost headings and tier labels that Firecrawl retained. A smaller payload is only better when it still preserves the evidence required to answer correctly.

Measure four things together: extracted tokens, field completeness, factual accuracy, and retrieval cost. Optimizing only the first can produce a very cheap wrong answer.

Use the Lightest Fetcher That Works

SituationRecommended pathStop condition
An official API, feed, export, or sitemap provides the dataUse the official structured sourceDo not scrape a less stable duplicate
Static or server-rendered HTMLFetcher / MCP getStop if terms disallow the use or the server rejects automation
Authorized page needs JavaScript to renderDynamicFetcher / MCP fetchStop after the required state loads; do not browse unrelated account areas
Owned site or explicitly authorized anti-bot testControlled use of StealthyFetcherWritten scope, request ceiling, logs, and no third-party targets
Managed search, crawl, extraction, or reliability is the priorityFirecrawl or another hosted serviceSet credit, page, and retention budgets
The site explicitly blocks or forbids the intended useAsk for permission or find a licensed sourceDo not escalate through stealth, proxies, or account rotation

Scrapling's documentation describes Fetcher as the fast HTTP option, DynamicFetcher as the browser path for JavaScript, and StealthyFetcher as the strongest anti-bot option. Capability is not permission. A 403 or challenge is a policy signal as well as a technical event; for ordinary research, it should usually end the attempt.

Workflow 1: Narrow Context Before Reasoning

Kacper asks for current OpenAI model prices and compares native web fetch, Scrapling MCP, and Firecrawl MCP. The strongest transferable pattern is not the vendor ranking. It is specifying the exact evidence shape before retrieval.

Use the regular HTTP retrieval tool on the authorized URL.
Return only the pricing table that contains the named models.
Preserve the nearest heading and every column label.
Output JSON with: model, tier, input_price, output_price, source_url, fetched_at.
Do not use a browser fallback. If the request is denied or the fields are incomplete, stop and report the gap.

This improves on a bare selector because it protects the context that makes the table interpretable. The validation step should reject rows without labels, currencies, units, or source URLs. Store the raw page or a content hash outside model context so the result can be audited without repeatedly paying to re-read it.

Workflow 2: Turn an Allowed Directory Into Research, Not Spam

The video uses a public BBB directory, asks Claude to qualify roofing companies, and exports a call list. The technical pipeline is easy to understand; the source choice is not safe to copy blindly. BBB's current terms grant access for direct use while restricting aggregation and sales or marketing use. Publicly viewable data is therefore not automatically an authorized prospecting dataset.

Rebuild the workflow around a source you own, license, or have permission to use: a chamber directory with a reuse license, an open government business register, opt-in event exhibitors, your CRM, or a vendor API whose contract permits prospecting. Then keep the agent's job narrow.

StageSafer ruleOutput
Source approvalRecord license, terms, purpose, geography, and allowed fieldsSource manifest
ExtractionCollect business-level fields only; avoid personal data unless necessary and lawfulCompany, category, location, public business URL
QualificationScore from observable business evidence, not invented intent or sensitive traitsEvidence-backed fit score with uncertainty
DeduplicationMerge repeated records and check an internal suppression listOne reviewable record per company
OutreachDraft only; a person verifies relevance, identity, channel rules, and opt-out requirementsApproved or rejected contact plan

Claude can rank rows, but it cannot establish that the source license permits the workflow. Put that decision before the scraper, not inside the lead-scoring prompt.

Workflow 3: Synthesize Design Patterns Without Copying

Kacper extracts colors, fonts, headings, CTA language, and structural patterns from five med-spa sites, then asks the agent to build a new landing page. The useful research method is cross-site pattern synthesis. The risky version copies source assets, distinctive copy, or a recognizable composition.

Reasonable market insightDo not reuseOriginal output to create
Common information architecture and recurring buyer questionsExact section order from one siteA new page hierarchy based on user needs
Palette families and contrast patterns across several referencesOne brand's exact color systemAn accessible palette with independent values
Typical CTA purpose, such as booking a consultationDistinctive slogans or proprietary copyNew copy in the client's voice
Common proof types: credentials, reviews, process, FAQsReviews, portraits, logos, photos, or videos from source sitesClient-owned evidence and licensed media
Shared typography categories and densityPaid font files or a signature type lockupLicensed fonts with an original scale
Analyze these authorized reference pages for recurring category patterns.
Do not reproduce copy, assets, testimonials, logos, exact palettes, or a source site's section sequence.
Return only: user questions, common proof types, interaction patterns, content gaps, accessibility risks, and design opportunities.
Then propose three original directions and explain how each differs from every source.

That turns competitive research into a brief rather than a cloning instruction. A designer should still review the references and final output for originality, licensing, accessibility, and misleading claims.

Scrapling Versus Firecrawl

QuestionScraplingFirecrawl
Operating modelLocal/open-source Python framework you runManaged API plus an open-source project
Primary advantagePrecise local extraction and control over parser, selectors, sessions, and spidersSearch, scrape, map, crawl, interact, and standardized LLM-ready outputs without operating the full stack
Cost shapeNo per-page library fee; you pay compute, proxies, maintenance, and model usageUsage-based credits or hosted plan plus model usage
Maintenance ownerYour teamMore of the infrastructure burden sits with the provider
Best fitPython teams, local control, stable targets, custom extraction, owned monitoringFast deployment, multi-site discovery, managed reliability, product teams avoiding scraper operations
Context efficiencyExcellent when a good selector removes irrelevant content before the modelStrong LLM-ready conversion; narrow extraction still needs configuration and validation

The video correctly avoids calling Scrapling a Firecrawl killer. Local software trades recurring vendor credits for engineering time and operational responsibility. The right comparison is total cost per verified record, including failures, retries, maintenance, latency, and human review.

Claim Audit

ClaimVerdictEvidence
Scrapling has more than 71,000 GitHub stars.Confirmed and already higherGitHub's API reported 72,225 stars on 3 August 2026. Star counts change continuously.
It is free and open source.Confirmed, with operating costsThe repository uses the BSD 3-Clause license. Browser compute, proxies, storage, upkeep, and model tokens remain real costs.
It cut 215K tokens to 3K.Creator-reported case studyThe transcript describes one raw-HTML test and one selector. No reproducible files, tokenizer details, or controlled benchmark are linked.
It bypasses every bot protection.FalseThe creator shows 403 failures. The official project claims strong anti-bot support, not guaranteed access to every target and configuration.
Independent testing shows 58 percent Cloudflare success.UnverifiedThe video does not link the researcher, targets, request count, configuration, proxies, dates, or raw results. We could not trace a reproducible primary benchmark for this exact number.
More than half of web traffic is automated.Supported within Imperva's datasetImperva reports automated traffic above 53 percent in its 2025 traffic analysis. This is vendor research, not a census of the entire Internet.
Public data is generally fine to scrape.Too broadPublic access does not override terms, robots directives, copyright, privacy, database rights, or purpose restrictions. BBB's own terms complicate the video's lead-list example.
Scrapling is an AI scraper.Misleading shorthandThe core parser and adaptive element matching run as software. MCP lets an AI agent direct and consume the extraction, but the library is not itself an LLM.

A Safe, Minimal Installation

Scrapling requires Python 3.10 or newer. Install it inside a dedicated virtual environment so browser and parser dependencies do not leak into unrelated projects. The official MCP path is:

python -m venv .venv
# Activate the virtual environment for your operating system.
python -m pip install --upgrade pip
python -m pip install "scrapling[ai]"
scrapling install

The last command installs browser dependencies. For parser-only use, the base scrapling package is smaller, but it does not include fetchers. The official docs also provide scrapling[fetchers], scrapling[shell], and scrapling[all] extras.

For an MCP client, point a local stdio server at the scrapling executable returned by where scrapling on Windows or which scrapling on macOS/Linux, with the argument mcp. Prefer local stdio for a first setup. Scrapling's docs warn that the optional streamable HTTP mode exposes URL-fetching tools to anyone who can reach the port unless authentication, allowed hosts, and TLS termination are configured correctly.

Before adding it to a main agent: inspect the repository and release, pin the tested version, run it in a disposable environment, restrict filesystem and network access, keep the MCP server local, and test against a site you own. Open source improves inspectability; it does not remove supply-chain or permission risk.

Scraped Content Is Untrusted Input

The current Scrapling MCP server sanitizes several hidden prompt-injection patterns when main_content_only is enabled: hidden CSS elements, aria-hidden content, template tags, HTML comments, and zero-width characters. That is useful defense in depth, not a complete trust boundary. A page can place malicious instructions in visible text, images, metadata, or data that looks relevant to the task.

  1. Separate retrieval from action. The scraper thread should not also have email-send, publish, purchase, delete, or credential-management tools.
  2. Keep main_content_only enabled. Add explicit selectors and a schema whenever possible.
  3. Label content as evidence, never instructions. The model's system rule should say that page text cannot change goals, tools, permissions, or output destinations.
  4. Validate structure. Reject unknown fields, oversized values, executable markup, and content without a source URL and timestamp.
  5. Retain provenance. Store the URL, retrieval method, selector, status, timestamp, and content hash with every record.
  6. Cap requests and retries. Use rate limits, caching, page budgets, and an explicit stop on access denial.
  7. Close browser sessions. Persistent sessions reduce overhead but retain state and consume resources until closed.
  8. Human-review consequential output. Qualification, outreach, publication, and business claims need a person accountable for the decision.

A Seven-Step Starter Blueprint

  1. Choose one permitted source. Prefer an official API or your own site; document why automated access is allowed.
  2. Write an acceptance test. Name the fields, one sample answer, freshness limit, and what counts as incomplete.
  3. Start with HTTP. Use get, no browser, one page, one retry ceiling.
  4. Add a selector. Keep the nearest heading and labels, not only values.
  5. Return a strict schema. Include provenance and an extraction_warning field.
  6. Compare three measurements. Tokens, completeness, and correctness; add total operating cost when scaling.
  7. Schedule only after a manual week. Then add caching, change detection, alerts, and a stop rule rather than silent retries forever.

A sensible first project is monitoring the pricing or documentation page of a service you depend on, where terms allow it. Extract one stable table, compare it with a saved snapshot, and send a human-readable change report. That tests the entire retrieval loop without starting with personal data, outreach, or adversarial websites.

Video Chapters

TimeTopicWhat to watch for
00:00IntroThe 71K-star and universal-bypass claims are introduced, then challenged.
00:45What web scraping isPages are converted into structures an agent can use.
01:45Four scraping use casesFresh information, prospect research, design research, and change monitoring.
02:45Workflow 1: token reductionNative fetch, Scrapling MCP, and Firecrawl MCP are compared.
05:25215K to 3KThe strongest creator-reported context example.
06:15Workflow 2: prospect listA useful pipeline paired with a source whose current terms require caution.
07:25Three fetcher typesHTTP, JavaScript browser, and protected-site paths.
10:00Workflow 3: five sites to one briefCross-site design pattern extraction and an AI-built page.
14:00What Scrapling isLocal parsing, adaptive matching, and the managed-versus-self-hosted tradeoff.
15:55Legal line and Cloudflare claimThe video's cautions are directionally useful, but some legal and benchmark claims need stronger sourcing.
16:35InstallationAgent-assisted MCP setup and the time-for-money tradeoff.

Bottom Line

Scrapling is compelling because it moves a basic context-engineering decision into the retrieval layer: do not pay a reasoning model to discover that most of the page is irrelevant. Its CSS-targeted MCP output, local operation, adaptive parser, fetcher choices, and spider framework make it a serious option for teams prepared to own the code and maintenance.

The 215K-to-3K example shows the upside, not the expected result for every page. The 58 percent Cloudflare figure is not sufficiently sourced. The BBB prospecting example should not be copied without permission. And anti-bot capability should never be confused with authorization.

The production pattern is straightforward: approved source, lightest fetcher, precise selector, strict schema, provenance, token and quality measurements, read-only agent, and human approval before consequences. Used that way, Scrapling can give an agent more useful context without pretending the web is permissionless.

Sources and Useful Links

Common questions

What is Scrapling?
Scrapling is a BSD-3-Clause Python framework for parsing, fetching, and crawling web pages. It includes CSS and XPath selection, adaptive element relocation, HTTP and browser fetchers, spiders, and an MCP server that can return targeted content to an AI agent.
Can Scrapling really reduce a 215,000-token page to 3,000 tokens?
Kacper Rutkiewicz reports that result for one test in which raw HTML used about 215,000 tokens and a CSS selector returned only the relevant pricing table at about 3,000. That is a 98.6 percent reduction and a 71.7 times smaller context payload, but it is a creator-run case study rather than a controlled, universal benchmark.
Does Scrapling bypass every Cloudflare-protected site?
No. The project documents anti-bot capabilities, but success depends on the target, challenge, network reputation, configuration, and timing. The video cites a 58 percent success rate without linking a reproducible methodology, so that number should not be treated as a verified benchmark.
Is Scrapling free?
The library is open source under the BSD 3-Clause license and can run locally without an account or API key. It is not costless at scale: browser compute, proxies, storage, monitoring, maintenance, and model tokens still carry costs.
Should I use Scrapling or Firecrawl?
Use Scrapling when you want local control, Python-level extraction, and are willing to operate the scraper. Use Firecrawl when a managed API, search, crawl orchestration, standardized LLM-ready output, and reduced maintenance are worth paying for. Many production stacks use both.
Is public web data automatically legal to scrape?
No. Public visibility is only one factor. You still need to review the site terms, robots directives, copyright, privacy, database rights, rate limits, purpose, and local law. The BBB directory example in the video deserves particular caution because BBB terms restrict aggregation and sales or marketing use.
Can scraped pages prompt-inject an AI agent?
Yes. Scrapling can sanitize common hidden-content injection patterns when main_content_only is enabled, but visible malicious instructions and other untrusted content can remain. Treat scraped text as data, keep tools read-only during retrieval, validate the output schema, and require approval before external actions.
Share
X LinkedIn Reddit
Build Yours

Want a system
like this one?

Book a free 30-minute call. We map your situation, identify the highest-impact automation, and figure out if we are a fit.

Book Free 30-min Call