Skip to content

Commit 64f728c

Browse files
[docs] update link extraction explanation & snippet (#918)
# why - to make sure people know to use `z.string().url()` in TS and `HttpUrl` in python ## before: <img width="716" height="462" alt="Screenshot 2025-07-26 at 12 08 07 PM" src="https://github.com/user-attachments/assets/3d0b9654-a1d1-4a31-a532-6bce1c6500b4" /> ## after: ### TypeScript <img width="772" height="531" alt="Screenshot 2025-07-26 at 12 01 54 PM" src="https://github.com/user-attachments/assets/beb055b9-b4d6-4420-a440-a8d6c42c95e7" /> ### Python <img width="728" height="517" alt="Screenshot 2025-07-26 at 12 01 58 PM" src="https://github.com/user-attachments/assets/9a06a441-eb28-4cb1-8c3d-b6d7051bf23b" />
1 parent 04978bd commit 64f728c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/reference/extract.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ Your output schema will look like:
4343
```
4444

4545
### Extract a link
46-
<Note>To extract links or URLs, specify this clearly in your instruction. See the snippet below. </Note>
46+
<Note>
47+
To extract links or URLs, in the TypeScript version of Stagehand, you'll need to define the relevant field as `z.string().url()`.
48+
In Python, you'll need to define it as `HttpUrl`.
49+
</Note>
4750

4851
Here is how an `extract` call might look for extracting a link or URL.
4952

@@ -52,7 +55,7 @@ Here is how an `extract` call might look for extracting a link or URL.
5255
const extraction = await page.extract({
5356
instruction: "extract the link to the 'contact us' page",
5457
schema: z.object({
55-
link: z.string().url(),
58+
link: z.string().url(), // note the usage of z.string().url() here
5659
}),
5760
});
5861

@@ -61,7 +64,7 @@ console.log("the link to the contact us page is: ", extraction.link);
6164

6265
```python Python
6366
class Extraction(BaseModel):
64-
link: HttpUrl
67+
link: HttpUrl # note the usage of HttpUrl here
6568

6669
extraction = await page.extract(
6770
"extract the link to the 'contact us' page",

0 commit comments

Comments
 (0)