contract-scraper
Version:
A customisable data scraper for the web based on JSON contracts
35 lines (34 loc) • 1.04 kB
TypeScript
import Fetcher, { ScrapedPage } from './src/fetcher/fetcher';
import { Provider } from './src/provider/provider';
import { PuppeteerNodeLaunchOptions } from 'puppeteer';
interface Attributes {
[name: string]: any;
}
declare class Scraper {
defaultAttributes: any;
private url;
private contract;
private attributes;
private puppeteerOptions;
constructor(url: string, contract: any, attributes?: Attributes, puppeteerOptions?: PuppeteerNodeLaunchOptions);
scrapePage(): Promise<any[]>;
getPageContents(): Promise<{
page: ScrapedPage;
$: cheerio.Root;
}>;
getScrapedItems(page: ScrapedPage, attributes: any): any[];
getAttributes(): {
[name: string]: any;
};
urlIsValid(): boolean;
contractIsValid(attributes: {
[name: string]: any;
}): {
message: string;
} | {
message: import("joi").ValidationError;
};
getFetcher(): Fetcher;
getProvider(page: ScrapedPage, attributes: any): Provider;
}
export default Scraper;