adaptive

command
v0.0.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Example: adaptive selectors that survive DOM changes.

Adaptive selectors learn an element signature on first successful match. On future runs, even when the producer renames or restructures the containing CSS class, similarity matching falls back to the saved signature so the scraper keeps working without code changes.

This example demonstrates the inline Response API on a static HTML fixture so it can be run without network access:

  • Run 1: original markup with class "product" — selector matches, signature is learned and persisted to ./adaptive_signatures.json
  • Run 2: same page but the class has been renamed to "item" — CSS selector finds nothing, but Response.Adaptive() falls back to the saved signature and still extracts the price

Run:

go run ./examples/adaptive/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL