flipkart-scraper
Version:
[](https://nodei.co/npm/flipkart-scraper/)
101 lines (100 loc) • 2.61 kB
TypeScript
/// <reference types="node" />
import { AxiosError } from 'axios';
import { EventEmitter } from 'events';
import { ResponseObject, ScraperOptions, ScrapedData, CategoryInfo, FinishedInfo, RetryInfo, StatsData } from './interfaces';
/**
Emitted when successful HTTP response from the Flipkart Affiliate server.
* @memberof FlipkartScraper
* @event
*/
export declare function response(httpResponse: ResponseObject): void;
/**
* Emitted when products returned from Flipkart affiliate API.
* @memberof FlipkartScraper
* @event
*/
export declare function data(scrapedData: ScrapedData): void;
/**
* Emitted if any errors occured.
* @memberof FlipkartScraper
* @event
*/
export declare function error(errorObj: AxiosError): void;
/**
* Emitted when all products scraped by category.
* @memberof FlipkartScraper
* @event
*/
export declare function categoryCompleted(completedCategoryInfo: CategoryInfo): void;
/**
* Emitted when scraper finished
* @memberof FlipkartScraper
* @event
*/
export declare function finished(finishedInfo: FinishedInfo): void;
/**
* Emitted when retry occurred
* @memberof FlipkartScraper
* @event
*/
export declare function retry(retryInfo: RetryInfo): void;
/**
* Emitted when retry failed 10 times
* @memberof FlipkartScraper
* @event
*/
export declare function retryHalted(retryHaltInfo: RetryInfo): void;
/**
* This the main class for Flipkart scraper
*/
export declare class FlipkartScraper extends EventEmitter {
private _affiliateId;
private _affiliateToken;
private _baseUrl;
private _queue;
private _maxRequest;
private _requestedCount;
private _processedCount;
private _concurrency;
private _maxPage;
private _startTime;
private _endTime;
private _totalProductsCount;
private _retryCount;
private _errorCount;
private _retryHaltCount;
private _pendingCategory;
private _completedCategory;
private _status;
private _downloadSize;
/**
* This is constructor of FlipkartScraper
* @param affiliateId
* @param affiliateToken
* @param options
*/
constructor(affiliateId: string, affiliateToken: string, options?: ScraperOptions);
stats(showAsNumbers?: boolean): StatsData;
/**
*
* @param categoriesToScrape
*/
start(categoriesToScrape?: string[]): Promise<string>;
/**
*
* @param params
*/
private _enqueue;
private _worker;
/**
*
* @param errorObj
* @param completedResponse
*/
private _onComplete;
/**
*
* @param url
*/
private _getData;
}