Skip to content

Commit ec5317c

Browse files
rsbryanSteven Bryan
andauthored
Fix Python example in observe.mdx (#1113)
# why The original example used JavaScript destructuring syntax [table] which doesn't work in Python. Fixed to use proper Python array indexing. # what changed fixed example to proper python syntax # test plan Co-authored-by: Steven Bryan <steven@mac.local.meter>
1 parent 34da7d3 commit ec5317c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

docs/basics/observe.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ const { data } = await page.extract({
109109
});
110110
```
111111
```python Python
112-
# Use observe to validate elements before extraction
113-
[ table ] = await page.observe("Find the data table")
112+
# Use observe to find the specific section (table, form, list, etc.)
113+
tables = await page.observe("Find the data table")
114+
table = tables[0] # Get the first suggestion
114115

116+
# Extract data using the selector to minimize context
115117
extraction = await page.extract(
116-
"Extract data from the table",
117-
schema=Data, # Pydantic schema
118-
selector=table.selector # Reduce context scope needed for extraction
118+
"Extract data from the table",
119+
schema=TableData, # Pydantic schema
120+
selector=table.selector # Focus extraction on just this table
119121
)
120122
```
121123
</CodeGroup>

0 commit comments

Comments
 (0)