Skip to main content

scrapemend

Self-healing web scraping for Python. Describe the data you want once. scrapemend extracts it with cached CSS selectors — and when a site changes its markup and those selectors break, a language model inspects the new page, repairs the selectors, and caches the fix. The next run is free again.

Traditional scrapers break every time a site is redesigned. scrapemend treats a broken selector as a cache miss, not a crash.


Why

Every scraper hits the same wall: you write selectors, the site ships a redesign, your selectors silently return nothing, and you go rewrite them by hand. Cloud "AI scraping" services solve the robustness problem but are expensive, send your target data through someone else's servers, and run an LLM call on every request.

scrapemend takes the middle path:

  • Cache first. Known selectors run with zero LLM cost — it's just parsing.
  • Heal on miss. The LLM is only called when selectors stop matching.
  • Self-hosted. It's a library, not a service. Your keys, your data.

Install

pip install scrapemend

Quickstart

from scrapemend import Scraper, Schema

schema = (
    Schema("product")
    .add("title", "the product name")
    .add("price", "the product price with currency")
)

scraper = Scraper()  # offline stub by default; plug in a real LLM to heal
result = scraper.extract("https://shop.example/p/1", schema)

print(result["title"], result["price"])
print("healed:", result.healed, "tokens:", result.tokens)

You describe what you want in plain language. You never hand-write a CSS selector — scrapemend discovers them, and re-discovers them when they break.

How it works

extract(url, schema)
      │
      ├─ cached selectors exist? ──► apply them
      │                               ├─ all fields matched ──► return (free)
      │                               └─ some field missed ──┐
      │                                                      ▼
      └─ no cache ─────────────────────────────────► LLM heals selectors
                                                      apply, cache, return

Because healing only runs on a miss, steady-state scraping costs nothing in tokens. You pay the model exactly when a site actually changes.

Status

Early alpha (0.0.1). The core pipeline — cache, parse, heal, re-cache — works and is covered by tests that run fully offline. A real OpenAI adapter is the next step; the LLM layer is provider-agnostic by design.

Roadmap

  • Cache-first / heal-on-miss pipeline
  • Offline, key-free test path
  • OpenAI adapter
  • Local-model adapter
  • HTML condensing for cheaper prompts
  • Pluggable cost/budget guards

License

MIT

Metadata

Release files for scrapemend 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrapemend 0.0.1
File Size Uploaded Provenance
scrapemend-0.0.1.tar.gz 16.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for scrapemend 0.0.1
File Interpreter ABI Platform
scrapemend-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.5 kB

Release files / scrapemend-0.0.1.tar.gz

Download URL scrapemend-0.0.1.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ee2d51b8410022bba25ffd93e192b998863c7d28e0838bdfa77cec036a76484e
BLAKE2b-256 checksum
How to use checksums
413cebad8955ad6a1042ba6e870ac68049e27be4ffce665b7001bc308f0d4344
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / scrapemend-0.0.1-py3-none-any.whl

Download URL scrapemend-0.0.1-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
262e9d35ea85b559aa39fef3a5d02e6c6bad1f0510f248a1575042ff8cfe1c04
BLAKE2b-256 checksum
How to use checksums
8b29274295cc46e0d8b825b48e533b7c360e9bc7e0be962a9fec398d47bb036e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for scrapemend 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page