-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathscrape.ts
More file actions
119 lines (113 loc) · 2.84 KB
/
Copy pathscrape.ts
File metadata and controls
119 lines (113 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* Types and interfaces for the scrape command
*/
export type ScrapeFormat =
| 'markdown'
| 'html'
| 'rawHtml'
| 'links'
| 'images'
| 'screenshot'
| 'summary'
| 'changeTracking'
| 'json'
| 'attributes'
| 'branding'
| 'video';
export interface VideoItem {
url: string;
sourceURL: string;
source: string;
kind?: string;
provider?: string;
title?: string;
thumbnail?: string;
description?: string;
duration?: string;
mimeType?: string;
width?: number;
height?: number;
metadata?: Record<string, unknown>;
}
export interface ScrapeDocument {
markdown?: string;
html?: string;
rawHtml?: string;
links?: string[];
images?: string[];
screenshot?: string;
summary?: string;
audio?: string;
video?: string;
videos?: VideoItem[];
answer?: string;
highlights?: string;
warning?: string;
actions?: Record<string, unknown>;
changeTracking?: Record<string, unknown>;
branding?: Record<string, unknown>;
metadata?: Record<string, unknown>;
[key: string]: unknown;
}
export interface ScrapeLocation {
/** ISO 3166-1 alpha-2 country code (e.g., 'US', 'DE', 'BR') */
country?: string;
/** List of language codes (e.g., ['en', 'es']) */
languages?: string[];
}
export interface ScrapeOptions {
/** URL to scrape */
url: string;
/** Output format(s) - single format or array of formats */
formats?: ScrapeFormat[];
/** Include only main content */
onlyMainContent?: boolean;
/** Wait time before scraping (ms) */
waitFor?: number;
/** Take screenshot */
screenshot?: boolean;
/** Take full page screenshot */
fullPageScreenshot?: boolean;
/** Include tags */
includeTags?: string[];
/** Exclude tags */
excludeTags?: string[];
/** API key for Firecrawl */
apiKey?: string;
/** API URL for Firecrawl */
apiUrl?: string;
/** Output file path */
output?: string;
/** Pretty print JSON output */
pretty?: boolean;
/** Force JSON output */
json?: boolean;
/** Show request timing and other useful information */
timing?: boolean;
/** Maximum age of cached content in milliseconds (API-level caching) */
maxAge?: number;
/** Location settings for geo-targeted scraping */
location?: ScrapeLocation;
/** Question to ask about the page content (query format) */
query?: string;
/** JSON schema for json format */
schema?: Record<string, unknown>;
/** Actions to run during scrape */
actions?: Record<string, unknown>[];
/** Proxy mode */
proxy?: string;
/** Persistent browser profile for maintaining state across scrapes */
profile?: {
name: string;
saveChanges?: boolean;
};
/** Enable lockdown mode for the scrape */
lockdown?: boolean;
/** Redact personally identifiable information from returned content */
redactPII?: boolean;
}
export interface ScrapeResult {
success: boolean;
data?: ScrapeDocument;
error?: string;
}