import { TotalumApiResponse } from "../common/interfaces"; import { FetchClient } from "../common/fetch-client"; export interface ScrapeRequestBody { url: string; asp?: boolean; render_js?: boolean; country?: string; proxy_pool?: 'public_datacenter_pool' | 'public_residential_pool'; headers?: Record; cookies?: Record; session?: string; session_sticky_proxy?: boolean; cache?: boolean; cache_ttl?: number; cost_budget?: number; timeout?: number; rendering_wait?: number; wait_for_selector?: string; auto_scroll?: boolean; js?: string; js_scenario?: any[]; format?: 'raw' | 'json' | 'text' | 'markdown' | 'clean_html'; format_options?: ('no_links' | 'no_images' | 'only_content')[]; method?: 'GET' | 'POST' | 'PUT' | 'DELETE'; body?: string; lang?: string[]; preset?: ScrapflyPresetName; extraction_model?: ScrapflyExtractionModel; extraction_prompt?: string; extraction_template?: string; } export interface ExtractRequestBody { url?: string; scrape_config?: Omit; content?: string; content_type?: 'text/html' | 'text/markdown'; extraction_model?: ScrapflyExtractionModel; extraction_prompt?: string; extraction_template?: string; } export interface ScreenshotRequestBody { url: string; format?: 'png' | 'jpeg' | 'webp' | 'gif'; capture?: 'viewport' | 'fullpage' | string; resolution?: string; country?: string; asp?: boolean; render_js?: boolean; wait_for_selector?: string; auto_scroll?: boolean; rendering_wait?: number; js?: string; cache?: boolean; cache_ttl?: number; options?: string[]; } export interface SearchAndExtractRequestBody { query: string; search_engine?: 'google'; max_results_to_scrape?: number; max_search_pages?: number; country?: string; smart_select?: boolean; selection_criteria?: string; extraction_prompt?: string; extraction_model?: ScrapflyExtractionModel; include_raw_content?: boolean; format?: 'text' | 'markdown' | 'clean_html'; } export interface ScrapeResponseData { url: string; status_code: number; content: string; content_type: string; headers: Record; format: string; extracted_data?: any; } export interface ExtractResponseData { content_type: string; data: any; data_quality?: { errors: string[]; fulfilled: boolean; fulfillment_percent: number; }; url?: string; } export interface ScreenshotResponseData { url: string; screenshot_binary: string; format: string; } export interface SearchAndExtractResult { position: number; source_url: string; title: string; snippet: string; was_selected: boolean; selection_reason?: string; page_metadata?: { final_url: string; status_code: number; content_type: string; content_length: number; }; extracted_data?: any; raw_content?: string; error?: string; } export interface SearchAndExtractResponseData { query: string; search_engine: string; total_search_results_found: number; results_analyzed: number; results_scraped: number; results: SearchAndExtractResult[]; skipped_results?: SearchAndExtractResult[]; total_cost: number; } export type ScrapflyPresetName = 'google' | 'amazon' | 'instagram' | 'linkedin' | 'twitter' | 'youtube' | 'ebay' | 'walmart' | 'generic'; export type ScrapflyExtractionModel = 'product' | 'product_listing' | 'article' | 'review_list' | 'real_estate_property' | 'real_estate_property_listing' | 'job_posting' | 'job_listing' | 'hotel' | 'hotel_listing' | 'event' | 'food_recipe' | 'organization' | 'social_media_post' | 'search_engine_results' | 'software' | 'stock' | 'vehicle_ad'; export declare class ScrappingService { private client; constructor(client: FetchClient); /** * Scrapes a web page and returns its content in the specified format. * Supports presets for popular platforms (Google, Amazon, Instagram, etc.). * @param {ScrapeRequestBody} body - Scrape configuration * @returns {Promise>} - The scraped page content */ scrape(body: ScrapeRequestBody): Promise>; /** * Extracts structured data from a URL or provided HTML/markdown content using AI models. * Can use pre-built extraction models (product, article, etc.) or custom prompts. * @param {ExtractRequestBody} body - Extraction configuration * @returns {Promise>} - The extracted structured data */ extract(body: ExtractRequestBody): Promise>; /** * Takes a screenshot of a web page. * @param {ScreenshotRequestBody} body - Screenshot configuration * @returns {Promise>} - The screenshot as base64 */ screenshot(body: ScreenshotRequestBody): Promise>; /** * Searches Google for a query, then scrapes and extracts data from the top results. * Supports smart AI-based source selection to only scrape the most relevant results. * @param {SearchAndExtractRequestBody} body - Search and extraction configuration * @returns {Promise>} - Search results with extracted data */ searchAndExtract(body: SearchAndExtractRequestBody): Promise>; }