File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,10 @@ Your output schema will look like:
43
43
```
44
44
45
45
### 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 >
47
50
48
51
Here is how an ` extract ` call might look for extracting a link or URL.
49
52
@@ -52,7 +55,7 @@ Here is how an `extract` call might look for extracting a link or URL.
52
55
const extraction = await page .extract ({
53
56
instruction: " extract the link to the 'contact us' page" ,
54
57
schema: z .object ({
55
- link: z .string ().url (),
58
+ link: z .string ().url (), // note the usage of z.string().url() here
56
59
}),
57
60
});
58
61
@@ -61,7 +64,7 @@ console.log("the link to the contact us page is: ", extraction.link);
61
64
62
65
``` python Python
63
66
class Extraction (BaseModel ):
64
- link: HttpUrl
67
+ link: HttpUrl # note the usage of HttpUrl here
65
68
66
69
extraction = await page.extract(
67
70
" extract the link to the 'contact us' page" ,
You can’t perform that action at this time.
0 commit comments