Skip to content

[docs]: add ignoreSelectors to docs for extract()#2088

Open
seanmcguire12 wants to merge 1 commit intomainfrom
docs-ignore-selectors-extract
Open

[docs]: add ignoreSelectors to docs for extract()#2088
seanmcguire12 wants to merge 1 commit intomainfrom
docs-ignore-selectors-extract

Conversation

@seanmcguire12
Copy link
Copy Markdown
Member

@seanmcguire12 seanmcguire12 commented May 6, 2026

what changed

  • adds new param to reference section
  • adds example to "targeted extract" section
Screenshot 2026-05-06 at 10 36 25 AM

Summary by cubic

Documented the new ignoreSelectors option for extract() to exclude elements (and their descendants) from the snapshot. Added a targeted-extract example and clarified how it interacts with selector, plus minor wording updates for supported page types.

Written for commit f039e45. Summary will update on new commits.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 6, 2026

⚠️ No Changeset found

Latest commit: f039e45

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant Client as User Code
    participant Stagehand as Stagehand Instance
    participant Extractor as Extract Engine
    participant DOM as DOM Snapshot Processor
    participant LLM as LLM Provider

    Note over Client,LLM: Core extract() flow with ignoreSelectors support

    Client->>Stagehand: extract(instruction, schema, { ignoreSelectors, selector? })
    Stagehand->>Extractor: process extraction request
    
    alt selector provided
        Extractor->>DOM: apply selector to locate target subtree
        DOM-->>Extractor: scoped DOM root
    else no selector
        Extractor->>DOM: capture full page DOM
        DOM-->>Extractor: full DOM tree
    end

    Note over DOM: CHANGED FLOW: ignoreSelectors filtering
    
    opt ignoreSelectors array provided
        Extractor->>DOM: filter out matching nodes and descendants
        DOM->>DOM: for each selector in ignoreSelectors
        DOM->>DOM: remove all matched elements + children
        DOM-->>Extractor: cleaned DOM snapshot
    end

    Extractor->>LLM: send instruction + schema + filtered snapshot
    LLM-->>Extractor: structured response
    Extractor->>Extractor: validate against schema
    
    alt validation passes
        Extractor-->>Stagehand: extracted data object
    else validation fails
        Extractor-->>Stagehand: error (LLMResponseError)
    end

    Stagehand-->>Client: return result or error
Loading

@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented May 6, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
stagehand 🟢 Ready View Preview May 6, 2026, 5:47 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants