@grabbit-labs/dynafetch 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,14 @@ Fetch any website like a real browser. One function call.
|
|
|
4
4
|
|
|
5
5
|
dynafetch provides Chrome-level TLS fingerprinting, JavaScript execution, and full network interception. The response includes fully rendered HTML and all captured requests.
|
|
6
6
|
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @grabbit-labs/dynafetch
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
7
15
|
```ts
|
|
8
16
|
import { dynafetch } from "@grabbit-labs/dynafetch";
|
|
9
17
|
|
|
@@ -60,6 +68,33 @@ const page = await dynafetch({
|
|
|
60
68
|
});
|
|
61
69
|
```
|
|
62
70
|
|
|
71
|
+
## AI SDK tool
|
|
72
|
+
|
|
73
|
+
Use dynafetch as a tool in the [Vercel AI SDK](https://sdk.vercel.ai):
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { z } from "zod";
|
|
77
|
+
import { generateText, tool } from "ai";
|
|
78
|
+
import { dynafetch } from "@grabbit-labs/dynafetch";
|
|
79
|
+
|
|
80
|
+
const result = await generateText({
|
|
81
|
+
model: yourModel,
|
|
82
|
+
tools: {
|
|
83
|
+
fetchPage: tool({
|
|
84
|
+
description: "Fetch a web page with full browser emulation and return the rendered HTML",
|
|
85
|
+
parameters: z.object({
|
|
86
|
+
url: z.string().url().describe("The URL to fetch"),
|
|
87
|
+
}),
|
|
88
|
+
execute: async ({ url }) => {
|
|
89
|
+
const page = await dynafetch(url);
|
|
90
|
+
return { html: page.html, status: page.status, framework: page.framework };
|
|
91
|
+
},
|
|
92
|
+
}),
|
|
93
|
+
},
|
|
94
|
+
prompt: "Get the homepage of example.com and summarize it",
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
63
98
|
## Quiescence tuning
|
|
64
99
|
|
|
65
100
|
dynafetch waits for async network activity to complete before returning. These options control that behavior:
|
|
@@ -90,7 +125,7 @@ const page = await dynafetch({
|
|
|
90
125
|
|
|
91
126
|
## Architecture
|
|
92
127
|
|
|
93
|
-
1. **Harvest**: fetches the HTML document through a
|
|
128
|
+
1. **Harvest**: fetches the HTML document through a TLS client matching Chrome's handshake. Parses scripts, modulepreloads, and SSR state.
|
|
94
129
|
|
|
95
130
|
2. **Module graph resolution**: recursively discovers and batch-fetches the full JS dependency tree in parallel. 700+ modules resolve in approximately 5 batch rounds.
|
|
96
131
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grabbit-labs/dynafetch",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Fetch any website like a real browser. Chrome TLS fingerprinting, JS execution, and request interception in one function call.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|