@@ -3,10 +3,13 @@ import { log } from './logger.js';
3
3
import { Rec , HttpMethod } from './types.js' ;
4
4
import { ScrapeConfigError } from './errors.js' ;
5
5
6
+ type ScreenshotFlags = "load_images" | "dark_mode" | "block_banners" | "high_quality" | "print_media_format" ;
7
+ type Format = "raw" | "json" | "text" | "markdown" | "clean_html" ;
8
+
6
9
export class ScrapeConfig {
7
10
static PUBLIC_DATACENTER_POOL = 'public_datacenter_pool' ;
8
11
static PUBLIC_RESIDENTIAL_POOL = 'public_residential_pool' ;
9
-
12
+
10
13
url : string ;
11
14
retry = true ;
12
15
method : HttpMethod = 'GET' ;
@@ -24,7 +27,7 @@ export class ScrapeConfig {
24
27
proxy_pool ?: string = null ;
25
28
session ?: string = null ;
26
29
tags : Set < string > = new Set < string > ( ) ;
27
- format ?: string = null ; // raw(unchanged)
30
+ format ?: Format = null ; // raw(unchanged)
28
31
correlation_id ?: string = null ;
29
32
cookies ?: Rec < string > = null ;
30
33
body ?: string = null ;
@@ -35,7 +38,7 @@ export class ScrapeConfig {
35
38
wait_for_selector ?: string = null ;
36
39
session_sticky_proxy = false ;
37
40
screenshots ?: Rec < any > = null ;
38
- screenshot_flags ?: string = null ;
41
+ screenshot_flags ?: ScreenshotFlags [ ] = null ;
39
42
webhook ?: string = null ;
40
43
timeout ?: number = null ; // in milliseconds
41
44
js_scenario ?: Rec < any > = null ;
@@ -62,7 +65,7 @@ export class ScrapeConfig {
62
65
proxy_pool ?: string ;
63
66
session ?: string ;
64
67
tags ?: Array < string > ;
65
- format ?: string ;
68
+ format ?: Format ;
66
69
correlation_id ?: string ;
67
70
cookies ?: Rec < string > ;
68
71
body ?: string ;
@@ -72,7 +75,7 @@ export class ScrapeConfig {
72
75
rendering_wait ?: number ;
73
76
wait_for_selector ?: string ;
74
77
screenshots ?: Rec < any > ;
75
- screenshot_flags ?: string ;
78
+ screenshot_flags ?: ScreenshotFlags [ ] ;
76
79
session_sticky_proxy ?: boolean ;
77
80
webhook ?: string ;
78
81
timeout ?: number ; // in milliseconds
@@ -201,7 +204,7 @@ export class ScrapeConfig {
201
204
params [ `screenshots[${ key } ]` ] = this . screenshots [ key ] ;
202
205
} ) ;
203
206
if ( this . screenshot_flags ) {
204
- params . screenshot_flags = this . screenshot_flags ;
207
+ params . screenshot_flags = this . screenshot_flags . join ( ',' ) ;
205
208
}
206
209
} else {
207
210
if ( this . screenshot_flags ) {
@@ -261,7 +264,7 @@ export class ScrapeConfig {
261
264
params . tags = Array . from ( this . tags ) . join ( ',' ) ;
262
265
}
263
266
if ( this . format ) {
264
- params . format = this . format ;
267
+ params . format = this . format . valueOf ( ) ;
265
268
}
266
269
if ( this . correlation_id ) {
267
270
params . correlation_id = this . correlation_id ;
0 commit comments