@@ -3,10 +3,13 @@ import { log } from './logger.js';
33import { Rec , HttpMethod } from './types.js' ;
44import { ScrapeConfigError } from './errors.js' ;
55
6+ type ScreenshotFlags = "load_images" | "dark_mode" | "block_banners" | "high_quality" | "print_media_format" ;
7+ type Format = "raw" | "json" | "text" | "markdown" | "clean_html" ;
8+
69export class ScrapeConfig {
710 static PUBLIC_DATACENTER_POOL = 'public_datacenter_pool' ;
811 static PUBLIC_RESIDENTIAL_POOL = 'public_residential_pool' ;
9-
12+
1013 url : string ;
1114 retry = true ;
1215 method : HttpMethod = 'GET' ;
@@ -24,7 +27,7 @@ export class ScrapeConfig {
2427 proxy_pool ?: string = null ;
2528 session ?: string = null ;
2629 tags : Set < string > = new Set < string > ( ) ;
27- format ?: string = null ; // raw(unchanged)
30+ format ?: Format = null ; // raw(unchanged)
2831 correlation_id ?: string = null ;
2932 cookies ?: Rec < string > = null ;
3033 body ?: string = null ;
@@ -35,7 +38,7 @@ export class ScrapeConfig {
3538 wait_for_selector ?: string = null ;
3639 session_sticky_proxy = false ;
3740 screenshots ?: Rec < any > = null ;
38- screenshot_flags ?: string = null ;
41+ screenshot_flags ?: ScreenshotFlags [ ] = null ;
3942 webhook ?: string = null ;
4043 timeout ?: number = null ; // in milliseconds
4144 js_scenario ?: Rec < any > = null ;
@@ -62,7 +65,7 @@ export class ScrapeConfig {
6265 proxy_pool ?: string ;
6366 session ?: string ;
6467 tags ?: Array < string > ;
65- format ?: string ;
68+ format ?: Format ;
6669 correlation_id ?: string ;
6770 cookies ?: Rec < string > ;
6871 body ?: string ;
@@ -72,7 +75,7 @@ export class ScrapeConfig {
7275 rendering_wait ?: number ;
7376 wait_for_selector ?: string ;
7477 screenshots ?: Rec < any > ;
75- screenshot_flags ?: string ;
78+ screenshot_flags ?: ScreenshotFlags [ ] ;
7679 session_sticky_proxy ?: boolean ;
7780 webhook ?: string ;
7881 timeout ?: number ; // in milliseconds
@@ -201,7 +204,7 @@ export class ScrapeConfig {
201204 params [ `screenshots[${ key } ]` ] = this . screenshots [ key ] ;
202205 } ) ;
203206 if ( this . screenshot_flags ) {
204- params . screenshot_flags = this . screenshot_flags ;
207+ params . screenshot_flags = this . screenshot_flags . join ( ',' ) ;
205208 }
206209 } else {
207210 if ( this . screenshot_flags ) {
@@ -261,7 +264,7 @@ export class ScrapeConfig {
261264 params . tags = Array . from ( this . tags ) . join ( ',' ) ;
262265 }
263266 if ( this . format ) {
264- params . format = this . format ;
267+ params . format = this . format . valueOf ( ) ;
265268 }
266269 if ( this . correlation_id ) {
267270 params . correlation_id = this . correlation_id ;
0 commit comments