online-judge-scraper
Version:
A library to extract information easily from various online judges.
26 lines (25 loc) • 674 B
JavaScript
/**
* Abstract base class for online judge problem scrapers.
* Each platform-specific scraper should extend this class and implement its methods.
*/
export class Scraper {
}
/**
* Error class for scraper errors.
*/
export class ScraperError extends Error {
judge;
type;
static ERROR_TYPES = {
INVALID_URL: 'Invalid URL',
VALIDATION_ERROR: 'Validation error',
PARSING_ERROR: 'Parsing error',
NETWORK_ERROR: 'Network error',
};
constructor(judge, type, message) {
super(`[${judge}] ${type}: ${message}`);
this.name = `${judge}ScraperError`;
this.judge = judge;
this.type = type;
}
}