UNPKG

@xcrap/core

Version:

Xcrap Core is the core package of the Xcrap framework for web scraping, offering tools such as HttpClient, BaseClient, Randomizer, Rotator, and support for proxies and pagination.

35 lines (34 loc) 1.12 kB
import { HtmlParser, JsonParser, MarkdownParser } from "@xcrap/parser"; export type HttpResponseOptions = { status: number; statusText: string; body: any; headers: Record<string, any>; attempts?: number; failedAttempts?: Array<{ error: string; timestamp: Date; }>; }; export type FaliedAttempt = { error: string; timestamp: Date; }; export declare class HttpResponse { readonly status: number; readonly statusText: string; readonly body: any; readonly headers: Record<string, string>; readonly attempts: number; readonly failedAttempts: FaliedAttempt[]; constructor({ body, status, statusText, headers, attempts, failedAttempts }: HttpResponseOptions); isSuccess(): boolean; getHeader(name: string): string | undefined; get text(): string; asJsonParser(ignoreHeader?: boolean): JsonParser; asMarkdownParser(ignoreHeader?: boolean): MarkdownParser; asHtmlParser(ignoreHeader?: boolean): HtmlParser; asParser<T>(constructor: new (body: any) => T): T; getFailedAttemptsCount(): number; hadRetries(): boolean; }