feat: adaptive (self-healing) selectors + logo, docs, bump to 1.5.1 - #126
Merged
Conversation
Adaptive selectors on Selector.css: auto_save=True fingerprints the matched element, adaptive=True relocates it by similarity when the selector later returns nothing, so scrapers survive site redesigns. Relocation improves on a naive similarity match on four fronts: weighted signals (a stable id/data-* hook outweighs weak ones instead of a flat average), anchor-relative fingerprints (nearest stable ancestor + depth, surviving path reshuffles), volatility-aware text (prices/dates/counts down-weighted), and tag-pruning before scoring. Returns a confidence + runner-up gap; fingerprints persist in a JSON store namespaced by site. 16 adaptive tests incl. relocation across a full redesign and a comparison showing the weighted scorer beats a uniform average. Docs: add the logo header, an adaptive-selectors section, a new title, and replace the tool/scraper tables with prose + a list command (the OMDb key note stays). Bump to 1.5.1.
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.
Adaptive (self-healing) selectors
Selector.cssgainsauto_save=True(fingerprint the matched element) andadaptive=True(relocate it by similarity when the selector later returns nothing), so scrapers survive site redesigns instead of silently breaking.Relocation improves on a naive similarity match on four fronts:
id/data-*hook far outweighs a sibling-tag list, so weak signals cannot dilute strong ones.Returns a confidence score + runner-up gap (
SelectorList.adaptive_confidence); fingerprints persist in a JSON store namespaced by site. Entirely opt-in — withoutadaptive=True, a broken selector returns empty exactly as before.Docs & polish
public/logo.png) + new title.Tests
16 adaptive tests, including relocation across a full redesign and a comparison showing the weighted scorer beats a uniform average on a volatile-text decoy that fools the uniform one. Full suite: 472 passed.
ruff check+ruff formatclean.