Skip to content

Commit f11a102

Browse files
feat: [feat]: add ignoreSelectors to extract()
1 parent 03f4dbe commit f11a102

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-dbbff1a35360850898f7d60588e257faeac145a73cfcae634cfeb1b70109b6af.yml
3-
openapi_spec_hash: 28c4b734a5309067c39bb4c4b709b9ab
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase/stagehand-7182c741edd5e22cda9bd855d31ca7e60a97a409222bb887edf87b9ce15dd493.yml
3+
openapi_spec_hash: 174581867a9191c491b22855b64c4f19
44
config_hash: a962ae71493deb11a1c903256fb25386

src/stagehand/types/session_extract_params.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Dict, Union, Optional
66
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
77

8+
from .._types import SequenceNotStr
89
from .._utils import PropertyInfo
910
from .model_config_param import ModelConfigParam
1011

@@ -37,6 +38,9 @@ class SessionExtractParamsBase(TypedDict, total=False):
3738

3839

3940
class Options(TypedDict, total=False):
41+
ignore_selectors: Annotated[SequenceNotStr[str], PropertyInfo(alias="ignoreSelectors")]
42+
"""Selectors for elements and subtrees that should be excluded from extraction"""
43+
4044
model: OptionsModel
4145
"""Model configuration object or model name string (e.g., 'openai/gpt-5-nano')"""
4246

tests/api_resources/test_sessions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ def test_method_extract_with_all_params_overload_1(self, client: Stagehand) -> N
443443
frame_id="frameId",
444444
instruction="Extract all product names and prices from the page",
445445
options={
446+
"ignore_selectors": ["nav", ".cookie-banner", "#sidebar-ads"],
446447
"model": {
447448
"model_name": "openai/gpt-5.4-mini",
448449
"api_key": "sk-some-openai-api-key",
@@ -511,6 +512,7 @@ def test_method_extract_with_all_params_overload_2(self, client: Stagehand) -> N
511512
frame_id="frameId",
512513
instruction="Extract all product names and prices from the page",
513514
options={
515+
"ignore_selectors": ["nav", ".cookie-banner", "#sidebar-ads"],
514516
"model": {
515517
"model_name": "openai/gpt-5.4-mini",
516518
"api_key": "sk-some-openai-api-key",
@@ -1373,6 +1375,7 @@ async def test_method_extract_with_all_params_overload_1(self, async_client: Asy
13731375
frame_id="frameId",
13741376
instruction="Extract all product names and prices from the page",
13751377
options={
1378+
"ignore_selectors": ["nav", ".cookie-banner", "#sidebar-ads"],
13761379
"model": {
13771380
"model_name": "openai/gpt-5.4-mini",
13781381
"api_key": "sk-some-openai-api-key",
@@ -1441,6 +1444,7 @@ async def test_method_extract_with_all_params_overload_2(self, async_client: Asy
14411444
frame_id="frameId",
14421445
instruction="Extract all product names and prices from the page",
14431446
options={
1447+
"ignore_selectors": ["nav", ".cookie-banner", "#sidebar-ads"],
14441448
"model": {
14451449
"model_name": "openai/gpt-5.4-mini",
14461450
"api_key": "sk-some-openai-api-key",

0 commit comments

Comments
 (0)