forked from qualweb/types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crawler.d.ts
45 lines (39 loc) · 1.39 KB
/
crawler.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
declare module "@qualweb/crawler" {
import { Browser, BrowserContext, Viewport } from "puppeteer";
import { LoadEvent } from "@qualweb/core";
interface CrawlOptions {
maxDepth?: number;
maxUrls?: number;
timeout?: number;
maxParallelCrawls?: number;
logging?: boolean;
}
class Crawler {
private readonly browser: Browser | BrowserContext;
private readonly viewport?: Viewport;
private readonly startingUrl: string;
private readonly isDomain: boolean;
private readonly waitUntil: LoadEvent | Array<LoadEvent>;
private urls: Array<string>;
constructor(
browser: Browser | BrowserContext,
startingUrl: string,
viewport?: Viewport,
waitUntil?: LoadEvent | Array<LoadEvent>
);
public crawl(options?: CrawlOptions): Promise<void>;
public getResults(): Array<string>;
private verifyStartingUrl(startingUrl: string): string;
private isStaringUrlADomain(startingUrl: string): boolean;
private log(
currentDepth: number,
currentUrlCount: number,
timer: number
): void;
private addUrlsToCrawl(urlsCrawled: any, urls: Array<string>): void;
private fetchPageLinks(url: string): Promise<Array<string>>;
private checkRelativePathsUrls(urls: Array<string>): Promise<Array<string>>;
private normalizeAndSort(urls: Array<string>): Array<string>;
}
export { CrawlOptions, Crawler };
}