UNPKG

source-scraper-puppeteer-runner

Version:

Provides the PuppeteerRunner class for scrapping.

32 lines (31 loc) 1.35 kB
import { IRunner, IRunnerArgs, IRunnerOptions, Runner } from 'source-scraper-core'; import { Browser, LaunchOptions, NavigationOptions, Page, Request } from 'puppeteer'; export interface IRequestInterceptorArgs { resourceType: string; url: string; page: Page; browser: Browser; request: Request; } export declare type IRequestInterceptor = (args: IRequestInterceptorArgs) => boolean; export interface IInitializerArgs { page: Page; browser: Browser; } export declare type IInitializer = (args: IInitializerArgs) => void; export interface IPuppeteerRunnerOptions extends IRunnerOptions { puppeteerConfig?: LaunchOptions; requestInterceptors?: IRequestInterceptor[]; init?: IInitializer; navigationOptions?: NavigationOptions; } export interface IPuppeteerRunnerArgs extends IRunnerArgs<IPuppeteerRunnerOptions> { browser: Browser; page: Page; } export interface IPuppeteerRunner<T> extends IRunner<T, IPuppeteerRunnerOptions, IPuppeteerRunnerArgs> { } export declare class PuppeteerRunner<T> extends Runner<T, IPuppeteerRunnerOptions, IPuppeteerRunnerArgs> implements IPuppeteerRunner<T> { defaultOptions: IPuppeteerRunnerOptions; protected exec(url: string, scraper: (args: IPuppeteerRunnerArgs) => Promise<T>, options: IPuppeteerRunnerOptions): Promise<T>; }