@mendable/firecrawl 1.2.2 → 1.18.0
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 +40 -0
- package/dist/index.cjs +778 -0
- package/dist/index.d.cts +452 -0
- package/dist/index.d.ts +452 -0
- package/dist/index.js +742 -0
- package/package.json +12 -14
- package/src/__tests__/index.test.ts +18 -9
- package/src/__tests__/v1/e2e_withAuth/index.test.ts +226 -113
- package/src/index.ts +1100 -130
- package/tsconfig.json +19 -105
- package/tsup.config.ts +9 -0
- package/build/cjs/index.js +0 -354
- package/build/cjs/package.json +0 -1
- package/build/esm/index.js +0 -346
- package/build/esm/package.json +0 -1
- package/types/index.d.ts +0 -260
package/README.md
CHANGED
|
@@ -145,6 +145,46 @@ watch.addEventListener("done", state => {
|
|
|
145
145
|
});
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
+
### Batch scraping multiple URLs
|
|
149
|
+
|
|
150
|
+
To batch scrape multiple URLs with error handling, use the `batchScrapeUrls` method. It takes the starting URLs and optional parameters as arguments. The `params` argument allows you to specify additional options for the batch scrape job, such as the output formats.
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
const batchScrapeResponse = await app.batchScrapeUrls(['https://firecrawl.dev', 'https://mendable.ai'], {
|
|
154
|
+
formats: ['markdown', 'html'],
|
|
155
|
+
})
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
#### Asynchronous batch scrape
|
|
160
|
+
|
|
161
|
+
To initiate an asynchronous batch scrape, utilize the `asyncBatchScrapeUrls` method. This method requires the starting URLs and optional parameters as inputs. The params argument enables you to define various settings for the scrape, such as the output formats. Upon successful initiation, this method returns an ID, which is essential for subsequently checking the status of the batch scrape.
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
const asyncBatchScrapeResult = await app.asyncBatchScrapeUrls(['https://firecrawl.dev', 'https://mendable.ai'], { formats: ['markdown', 'html'] });
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Batch scrape with WebSockets
|
|
168
|
+
|
|
169
|
+
To use batch scrape with WebSockets, use the `batchScrapeUrlsAndWatch` method. It takes the starting URL and optional parameters as arguments. The `params` argument allows you to specify additional options for the batch scrape job, such as the output formats.
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
// Batch scrape multiple URLs with WebSockets:
|
|
173
|
+
const watch = await app.batchScrapeUrlsAndWatch(['https://firecrawl.dev', 'https://mendable.ai'], { formats: ['markdown', 'html'] });
|
|
174
|
+
|
|
175
|
+
watch.addEventListener("document", doc => {
|
|
176
|
+
console.log("DOC", doc.detail);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
watch.addEventListener("error", err => {
|
|
180
|
+
console.error("ERR", err.detail.error);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
watch.addEventListener("done", state => {
|
|
184
|
+
console.log("DONE", state.detail.status);
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
148
188
|
## Error Handling
|
|
149
189
|
|
|
150
190
|
The SDK handles errors returned by the Firecrawl API and raises appropriate exceptions. If an error occurs during a request, an exception will be raised with a descriptive error message. The examples above demonstrate how to handle these errors using `try/catch` blocks.
|