UNPKG

@35iter/spider-core

Version:

使用 puppetter-cluster 的爬虫工具。

28 lines (27 loc) 866 B
import { Page } from "puppeteer"; import { Cluster } from "@35iter/puppeteer-cluster"; import { TaskFunction } from "@35iter/puppeteer-cluster/dist/Cluster"; declare type Config = { maxConcurrency: number; logger?: any; }; export declare function setConfig(_config?: Partial<Config>): void; export declare function launch(): Promise<Cluster<any, any>>; export declare function destory(): Promise<void>; export declare function openURL({ url, task, check, checkTimeout, device, }: { url: string; task: TaskFunction<any, any>; /** * 页面是否加载完成的检查,对于前后端分离的页面有奇效 */ check?: (page: Page) => Promise<boolean>; /** * check 超时时间 */ checkTimeout?: number; /** * 设备宽度 */ device?: "pc" | "mobile" | number; }): Promise<any | null>; export {};