class BaseExtractor {
  constructor() {
    this.patterns = [];
  }

  canHandle(url) {
    try {
      const hostname = new URL(url).hostname.replace('www.', '');
      return this.patterns.some(p => p.test(hostname));
    } catch (e) {
      return false;
    }
  }

  // Override getExtractCode() in subclass to return a string of page.evaluate JS code
  getExtractCode() {
    throw new Error('override getExtractCode()');
  }
}

module.exports = BaseExtractor;
